chiark / gitweb /
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 95ea45d..7ef8097 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 16ffbd3..ab4363a 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);