void hashmap_free(Hashmap*h) {
+ /* Free the hashmap, but nothing in it */
+
if (!h)
return;
}
void hashmap_free_free(Hashmap *h) {
+
+ /* Free the hashmap and all data objects in it, but not the
+ * keys */
+
if (!h)
return;
return NULL;
hash = h->hash_func(key) % NBUCKETS;
-
- if (!(e = hash_scan(h, hash, key)))
+ e = hash_scan(h, hash, key);
+ if (!e)
return NULL;
return e->value;
}
+bool hashmap_contains(Hashmap *h, const void *key) {
+ unsigned hash;
+
+ if (!h)
+ return false;
+
+ hash = h->hash_func(key) % NBUCKETS;
+
+ if (!hash_scan(h, hash, key))
+ return false;
+
+ return true;
+}
+
void* hashmap_remove(Hashmap *h, const void *key) {
struct hashmap_entry *e;
unsigned hash;