chiark / gitweb /
path-util: in path_is_mount_point() fall back to the classic stat() test if fs does...
[elogind.git] / src / shared / hashmap.c
index e2395d4d4290caab9eb1e5a2024ba7fb294d1324..0a044b85ad25a7901025d1a8ae2474a83ab00d66 100644 (file)
@@ -378,6 +378,20 @@ void* hashmap_get(Hashmap *h, const void *key) {
         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;