summaryrefslogtreecommitdiffstats
path: root/src/install/hashmap.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 10:33:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 10:33:11 +0000
commitae3ecffbd2e40760fef5dc09db30ea8a81abec70 (patch)
treef3b77bfda1bae06d3326ef27c3cb61539e7f93cc /src/install/hashmap.c
parentAdding debian version 102-3. (diff)
downloaddracut-ae3ecffbd2e40760fef5dc09db30ea8a81abec70.tar.xz
dracut-ae3ecffbd2e40760fef5dc09db30ea8a81abec70.zip
Merging upstream version 103.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/install/hashmap.c')
-rw-r--r--src/install/hashmap.c20
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)