mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 12:14:36 +03:00
Add debugging sanity checks.
This commit is contained in:
13
Hashtable.c
13
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) {
|
||||
|
Reference in New Issue
Block a user