]> err.no Git - systemd/commitdiff
hashmap: add hashmap_first_key()
authorLennart Poettering <lennart@poettering.net>
Mon, 19 Dec 2011 18:54:51 +0000 (19:54 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 19 Dec 2011 18:54:51 +0000 (19:54 +0100)
src/hashmap.c
src/hashmap.h

index 95ea45da4893662d42b569f16914acf6ec4101e9..7ef809746d3a67f0cfbf4220bbcd05bd673bce93 100644 (file)
@@ -558,6 +558,17 @@ void* hashmap_first(Hashmap *h) {
         return h->iterate_list_head->value;
 }
 
+void* hashmap_first_key(Hashmap *h) {
+
+        if (!h)
+                return NULL;
+
+        if (!h->iterate_list_head)
+                return NULL;
+
+        return (void*) h->iterate_list_head->key;
+}
+
 void* hashmap_last(Hashmap *h) {
 
         if (!h)
index 16ffbd392216e77a126ef1d8ef0d0877470c49b7..ab4363a7a3ae34230049accaf7e7b7465e512097 100644 (file)
@@ -74,6 +74,7 @@ void hashmap_clear(Hashmap *h);
 void *hashmap_steal_first(Hashmap *h);
 void *hashmap_steal_first_key(Hashmap *h);
 void* hashmap_first(Hashmap *h);
+void* hashmap_first_key(Hashmap *h);
 void* hashmap_last(Hashmap *h);
 
 char **hashmap_get_strv(Hashmap *h);