summaryrefslogtreecommitdiff
path: root/src/shared/hashmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/hashmap.c')
-rw-r--r--src/shared/hashmap.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/shared/hashmap.c b/src/shared/hashmap.c
index 65b7b74128..5c3efa8dd3 100644
--- a/src/shared/hashmap.c
+++ b/src/shared/hashmap.c
@@ -582,6 +582,34 @@ void* hashmap_remove(Hashmap *h, const void *key) {
return data;
}
+void* hashmap_remove2(Hashmap *h, const void *key, void **rkey) {
+ struct hashmap_entry *e;
+ unsigned hash;
+ void *data;
+
+ if (!h) {
+ if (rkey)
+ *rkey = NULL;
+ return NULL;
+ }
+
+ hash = bucket_hash(h, key);
+ e = hash_scan(h, hash, key);
+ if (!e) {
+ if (rkey)
+ *rkey = NULL;
+ return NULL;
+ }
+
+ data = e->value;
+ if (rkey)
+ *rkey = (void*) e->key;
+
+ remove_entry(h, e);
+
+ return data;
+}
+
int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value) {
struct hashmap_entry *e;
unsigned old_hash, new_hash;