u/hashmap: Add "empty" function.

Used for cleanup assertions to start with: i.e. at some known point,
the hash map should be empty.
This commit is contained in:
Ryan Pavlik 2020-06-15 16:36:52 -05:00
parent 4a4bed8df4
commit 821706e0e4
2 changed files with 12 additions and 0 deletions

View file

@ -73,6 +73,12 @@ u_hashmap_int_erase(struct u_hashmap_int *hmi, uint64_t key)
return 0;
}
bool
u_hashmap_int_empty(const struct u_hashmap_int *hmi)
{
return hmi->map.empty();
}
extern "C" void
u_hashmap_int_clear_and_call_for_each(struct u_hashmap_int *hmi,
u_hashmap_int_callback cb,

View file

@ -41,6 +41,12 @@ u_hashmap_int_insert(struct u_hashmap_int *hmi, uint64_t key, void *value);
int
u_hashmap_int_erase(struct u_hashmap_int *hmi, uint64_t key);
/*!
* Is the hash map empty?
*/
bool
u_hashmap_int_empty(const struct u_hashmap_int *hmi);
/*!
* First clear the hashmap and then call the given callback with each item that
* was in the hashmap.