aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2008-05-28 18:32:05 +0000
committerWillem Jan Palenstijn2008-05-28 18:32:05 +0000
commit90bf3de2d66a6605fad7f6a050fae6d277d15f56 (patch)
tree344f092bbde67ff93d3ff8c2c1b64310ed864879
parent16b0905bb0b5e164a2014031749a61c24c6af32b (diff)
downloadscummvm-rg350-90bf3de2d66a6605fad7f6a050fae6d277d15f56.tar.gz
scummvm-rg350-90bf3de2d66a6605fad7f6a050fae6d277d15f56.tar.bz2
scummvm-rg350-90bf3de2d66a6605fad7f6a050fae6d277d15f56.zip
Decrement _nele when erasing an element from hashmap, and add a test-case for this bug.
svn-id: r32343
-rw-r--r--common/hashmap.h1
-rw-r--r--test/common/hashmap.h3
2 files changed, 4 insertions, 0 deletions
diff --git a/common/hashmap.h b/common/hashmap.h
index 81a4b0d17e..1bae44e98e 100644
--- a/common/hashmap.h
+++ b/common/hashmap.h
@@ -535,6 +535,7 @@ void HashMap<Key, Val, HashFunc, EqualFunc>::erase(const Key &key) {
}
}
_arr[i] = NULL;
+ _nele--;
return;
}
diff --git a/test/common/hashmap.h b/test/common/hashmap.h
index 883e965065..5aa609bc00 100644
--- a/test/common/hashmap.h
+++ b/test/common/hashmap.h
@@ -37,6 +37,9 @@ class HashMapTestSuite : public CxxTest::TestSuite
TS_ASSERT( !container.contains(1) );
container[1] = 42;
TS_ASSERT( container.contains(1) );
+ container.erase(0);
+ container.erase(1);
+ TS_ASSERT( container.empty() );
}
void test_lookup( void )