chiark / gitweb /
readahead: implement minimal readahead logic based on fanotify(), mincore() and reada...
[elogind.git] / src / hashmap.c
index 6b6e909ba385a3542dc7944d95b2eb7006ba2e42..4b187057ec34f8af4d5de0fcb7bbdff8159438dc 100644 (file)
@@ -173,6 +173,15 @@ void hashmap_free(Hashmap*h) {
         free(h);
 }
 
+void hashmap_free_free(Hashmap *h) {
+        void *p;
+
+        while ((p = hashmap_steal_first(h)))
+                free(p);
+
+        hashmap_free(h);
+}
+
 void hashmap_clear(Hashmap *h) {
         if (!h)
                 return;
@@ -467,6 +476,21 @@ void* hashmap_steal_first(Hashmap *h) {
         return data;
 }
 
+void* hashmap_steal_first_key(Hashmap *h) {
+        void *key;
+
+        if (!h)
+                return NULL;
+
+        if (!h->iterate_list_head)
+                return NULL;
+
+        key = (void*) h->iterate_list_head->key;
+        remove_entry(h, h->iterate_list_head);
+
+        return key;
+}
+
 unsigned hashmap_size(Hashmap *h) {
 
         if (!h)