Add debugging sanity checks.

This commit is contained in:
Hisham Muhammad
2006-11-12 21:52:14 +00:00
parent c90a445103
commit 36848494f5
4 changed files with 37 additions and 2 deletions

View File

@ -46,6 +46,19 @@ bool Hashtable_isConsistent(Hashtable* this) {
return items == this->items;
}
int Hashtable_count(Hashtable* this) {
int items = 0;
for (int i = 0; i < this->size; i++) {
HashtableItem* bucket = this->buckets[i];
while (bucket) {
items++;
bucket = bucket->next;
}
}
assert(items == this->items);
return items;
}
#endif
HashtableItem* HashtableItem_new(int key, void* value) {