}
void hashmap_free_free(Hashmap *h) {
+ if (!h)
+ return;
+
hashmap_clear_free(h);
hashmap_free(h);
}
void hashmap_clear_free(Hashmap *h) {
void *p;
- assert(h);
+ if (!h)
+ return;
while ((p = hashmap_steal_first(h)))
free(p);
return e->value;
}
+bool hashmap_contains(Hashmap *h, const void *key) {
+ unsigned hash;
+ struct hashmap_entry *e;
+
+ if (!h)
+ return false;
+
+ hash = h->hash_func(key) % NBUCKETS;
+
+ if (!(e = hash_scan(h, hash, key)))
+ return false;
+
+ return true;
+}
+
void* hashmap_remove(Hashmap *h, const void *key) {
struct hashmap_entry *e;
unsigned hash;