diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-12-19 19:54:51 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-12-19 19:54:51 +0100 |
commit | 2e4a6ff47b311216829ed0f48f17ee9bc35641dc (patch) | |
tree | 30eb3d742914c6d6ed2538baa3a53e0bf5106b65 /src | |
parent | 5079a105e701f17439635e76d8cb3052badbb34c (diff) |
hashmap: add hashmap_first_key()
Diffstat (limited to 'src')
-rw-r--r-- | src/hashmap.c | 11 | ||||
-rw-r--r-- | src/hashmap.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/hashmap.c b/src/hashmap.c index 95ea45da48..7ef809746d 100644 --- a/src/hashmap.c +++ b/src/hashmap.c @@ -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) diff --git a/src/hashmap.h b/src/hashmap.h index 16ffbd3922..ab4363a7a3 100644 --- a/src/hashmap.h +++ b/src/hashmap.h @@ -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); |