summaryrefslogtreecommitdiff
path: root/src/shared/hashmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/hashmap.c')
-rw-r--r--src/shared/hashmap.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/hashmap.c b/src/shared/hashmap.c
index e2395d4d42..be37a3659d 100644
--- a/src/shared/hashmap.c
+++ b/src/shared/hashmap.c
@@ -378,6 +378,21 @@ void* hashmap_get(Hashmap *h, const void *key) {
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;