summaryrefslogtreecommitdiff
path: root/src/basic/hashmap.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-12-17 18:42:09 +0100
committerLennart Poettering <lennart@poettering.net>2018-12-18 11:28:10 +0100
commitc380b84d8b88ca61371d8fdb77d5719c778700fc (patch)
tree92b2d86fa32ec2f197836400f3bef98c0c9c5353 /src/basic/hashmap.h
parent1a126325eb26decfe4d3bb64c6ec1c27cafb8c73 (diff)
downloadsystemd-c380b84d8b88ca61371d8fdb77d5719c778700fc.tar.gz
hashmap: rework hashmap_clear() to be more defensive
Let's first remove an item from the hashmap and only then destroy it. This makes sure that destructor functions can mdoify the hashtables in their own codee and we won't be confused by that.
Diffstat (limited to 'src/basic/hashmap.h')
-rw-r--r--src/basic/hashmap.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/basic/hashmap.h b/src/basic/hashmap.h
index a330a1d494..5bf807a76f 100644
--- a/src/basic/hashmap.h
+++ b/src/basic/hashmap.h
@@ -191,7 +191,11 @@ static inline void *ordered_hashmap_remove2(OrderedHashmap *h, const void *key,
return hashmap_remove2(PLAIN_HASHMAP(h), key, rkey);
}
-void *hashmap_remove_value(Hashmap *h, const void *key, void *value);
+void *internal_hashmap_remove_value(HashmapBase *h, const void *key, void *value);
+static inline void *hashmap_remove_value(Hashmap *h, const void *key, void *value) {
+ return internal_hashmap_remove_value(HASHMAP_BASE(h), key, value);
+}
+
static inline void *ordered_hashmap_remove_value(OrderedHashmap *h, const void *key, void *value) {
return hashmap_remove_value(PLAIN_HASHMAP(h), key, value);
}