[Scummvm-cvs-logs] SF.net SVN: scummvm:[44257] scummvm/branches/branch-1-0-0/common/hashmap.h

wjpalenstijn at users.sourceforge.net wjpalenstijn at users.sourceforge.net
Tue Sep 22 14:33:20 CEST 2009


Revision: 44257
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44257&view=rev
Author:   wjpalenstijn
Date:     2009-09-22 12:33:20 +0000 (Tue, 22 Sep 2009)

Log Message:
-----------
Backport of r44256: don't return dummyNode when iterating a HashMap

Modified Paths:
--------------
    scummvm/branches/branch-1-0-0/common/hashmap.h

Modified: scummvm/branches/branch-1-0-0/common/hashmap.h
===================================================================
--- scummvm/branches/branch-1-0-0/common/hashmap.h	2009-09-22 11:58:59 UTC (rev 44256)
+++ scummvm/branches/branch-1-0-0/common/hashmap.h	2009-09-22 12:33:20 UTC (rev 44257)
@@ -161,6 +161,7 @@
 			assert(_idx <= _hashmap->_mask);
 			Node *node = _hashmap->_storage[_idx];
 			assert(node != 0);
+			assert(node != &_hashmap->_dummyNode);
 			return node;
 		}
 
@@ -179,7 +180,7 @@
 			assert(_hashmap);
 			do {
 				_idx++;
-			} while (_idx <= _hashmap->_mask && _hashmap->_storage[_idx] == 0);
+			} while (_idx <= _hashmap->_mask && (_hashmap->_storage[_idx] == 0 || _hashmap->_storage[_idx] == &_hashmap->_dummyNode));
 			if (_idx > _hashmap->_mask)
 				_idx = (uint)-1;
 
@@ -231,7 +232,7 @@
 	iterator	begin() {
 		// Find and return the first non-empty entry
 		for (uint ctr = 0; ctr <= _mask; ++ctr) {
-			if (_storage[ctr])
+			if (_storage[ctr] && _storage[ctr] != &_dummyNode)
 				return iterator(ctr, this);
 		}
 		return end();
@@ -243,7 +244,7 @@
 	const_iterator	begin() const {
 		// Find and return the first non-empty entry
 		for (uint ctr = 0; ctr <= _mask; ++ctr) {
-			if (_storage[ctr])
+			if (_storage[ctr] && _storage[ctr] != &_dummyNode)
 				return const_iterator(ctr, this);
 		}
 		return end();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list