diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:33:11 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:33:11 +0000 |
commit | 203af7302854f453fa4a05ecefd4403b6c8a4f8d (patch) | |
tree | 967fdacafe332baabd12b57725505c138d0f3bbf /src/install/hashmap.c | |
parent | Adding upstream version 102. (diff) | |
download | dracut-upstream.tar.xz dracut-upstream.zip |
Adding upstream version 103.upstream/103upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/install/hashmap.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/install/hashmap.c b/src/install/hashmap.c index ff0f681..e6f8c79 100644 --- a/src/install/hashmap.c +++ b/src/install/hashmap.c @@ -273,20 +273,32 @@ int hashmap_replace(Hashmap *h, const void *key, void *value) return hashmap_put(h, key, value); } -void *hashmap_get(Hashmap *h, const void *key) +int hashmap_get_exists(Hashmap *h, const void *key, void **value) { unsigned int hash; struct hashmap_entry *e; + *value = NULL; + if (!h) - return NULL; + return 0; hash = h->hash_func(key) % NBUCKETS; if (!(e = hash_scan(h, hash, key))) - return NULL; + return 0; - return e->value; + *value = e->value; + return 1; +} + +void *hashmap_get(Hashmap *h, const void *key) +{ + void *ret; + + hashmap_get_exists(h, key, &ret); + + return ret; } void *hashmap_remove(Hashmap *h, const void *key) |