diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2006-11-12 21:52:14 +0000 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2006-11-12 21:52:14 +0000 |
commit | 36848494f57ff8cdc95876c95c36052eca40ccdb (patch) | |
tree | d3d50472fa7098e2a27127899e7a9ed20af22fc0 /Hashtable.c | |
parent | c90a4451032d54c3f29cd6b567ba62126fe65208 (diff) |
Add debugging sanity checks.
Diffstat (limited to 'Hashtable.c')
-rw-r--r-- | Hashtable.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Hashtable.c b/Hashtable.c index c1e63c05..4cd63109 100644 --- a/Hashtable.c +++ b/Hashtable.c @@ -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) { |