diff options
| author | Johannes Schickel | 2009-09-22 11:58:59 +0000 | 
|---|---|---|
| committer | Johannes Schickel | 2009-09-22 11:58:59 +0000 | 
| commit | 4f65994267b88e46159491255147feda98648816 (patch) | |
| tree | 4c6e27262d52df821e9fee3606b516842b06f773 | |
| parent | 161659052b2936f9fb4559f70b3ceb9148a10da3 (diff) | |
| download | scummvm-rg350-4f65994267b88e46159491255147feda98648816.tar.gz scummvm-rg350-4f65994267b88e46159491255147feda98648816.tar.bz2 scummvm-rg350-4f65994267b88e46159491255147feda98648816.zip  | |
Fix regression in 44236, which caused iterators to see dummy node entries as valid entries.
svn-id: r44256
| -rw-r--r-- | common/hashmap.h | 11 | 
1 files changed, 6 insertions, 5 deletions
diff --git a/common/hashmap.h b/common/hashmap.h index 4a23ca7563..99380707b7 100644 --- a/common/hashmap.h +++ b/common/hashmap.h @@ -160,6 +160,7 @@ public:  			assert(_idx <= _hashmap->_mask);  			Node *node = _hashmap->_storage[_idx];  			assert(node != 0); +			assert(node != HASHMAP_DUMMY_NODE);  			return node;  		} @@ -178,7 +179,7 @@ public:  			assert(_hashmap);  			do {  				_idx++; -			} while (_idx <= _hashmap->_mask && _hashmap->_storage[_idx] == 0); +			} while (_idx <= _hashmap->_mask && (_hashmap->_storage[_idx] == 0 || _hashmap->_storage[_idx] == HASHMAP_DUMMY_NODE));  			if (_idx > _hashmap->_mask)  				_idx = (uint)-1; @@ -231,7 +232,7 @@ public:  	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] != HASHMAP_DUMMY_NODE)  				return iterator(ctr, this);  		}  		return end(); @@ -243,7 +244,7 @@ public:  	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] != HASHMAP_DUMMY_NODE)  				return const_iterator(ctr, this);  		}  		return end(); @@ -254,14 +255,14 @@ public:  	iterator	find(const Key &key) {  		uint ctr = lookup(key); -		if (_storage[ctr]) +		if (_storage[ctr] && _storage[ctr] != HASHMAP_DUMMY_NODE)  			return iterator(ctr, this);  		return end();  	}  	const_iterator	find(const Key &key) const {  		uint ctr = lookup(key); -		if (_storage[ctr]) +		if (_storage[ctr] && _storage[ctr] != HASHMAP_DUMMY_NODE)  			return const_iterator(ctr, this);  		return end();  	}  | 
