summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/hashmap.c15
-rw-r--r--src/shared/hashmap.h2
-rw-r--r--src/shared/set.c4
-rw-r--r--src/shared/set.h2
4 files changed, 18 insertions, 5 deletions
diff --git a/src/shared/hashmap.c b/src/shared/hashmap.c
index 5d1e63208a..ab00957306 100644
--- a/src/shared/hashmap.c
+++ b/src/shared/hashmap.c
@@ -277,11 +277,7 @@ void hashmap_free(Hashmap*h) {
}
void hashmap_free_free(Hashmap *h) {
- void *p;
-
- while ((p = hashmap_steal_first(h)))
- free(p);
-
+ hashmap_clear_free(h);
hashmap_free(h);
}
@@ -293,6 +289,15 @@ void hashmap_clear(Hashmap *h) {
remove_entry(h, h->iterate_list_head);
}
+void hashmap_clear_free(Hashmap *h) {
+ void *p;
+
+ assert(h);
+
+ while ((p = hashmap_steal_first(h)))
+ free(p);
+}
+
static struct hashmap_entry *hash_scan(Hashmap *h, unsigned hash, const void *key) {
struct hashmap_entry *e;
assert(h);
diff --git a/src/shared/hashmap.h b/src/shared/hashmap.h
index fcf2cb1c81..deefd9a804 100644
--- a/src/shared/hashmap.h
+++ b/src/shared/hashmap.h
@@ -71,6 +71,8 @@ void *hashmap_iterate_backwards(Hashmap *h, Iterator *i, const void **key);
void *hashmap_iterate_skip(Hashmap *h, const void *key, Iterator *i);
void hashmap_clear(Hashmap *h);
+void hashmap_clear_free(Hashmap *h);
+
void *hashmap_steal_first(Hashmap *h);
void *hashmap_steal_first_key(Hashmap *h);
void* hashmap_first(Hashmap *h);
diff --git a/src/shared/set.c b/src/shared/set.c
index 20e457eda4..f5c7c37cab 100644
--- a/src/shared/set.c
+++ b/src/shared/set.c
@@ -116,3 +116,7 @@ Set* set_copy(Set *s) {
void set_clear(Set *s) {
hashmap_clear(MAKE_HASHMAP(s));
}
+
+void set_clear_free(Set *s) {
+ hashmap_clear_free(MAKE_HASHMAP(s));
+}
diff --git a/src/shared/set.h b/src/shared/set.h
index a4653b3a45..18921df427 100644
--- a/src/shared/set.h
+++ b/src/shared/set.h
@@ -56,6 +56,8 @@ void *set_iterate_backwards(Set *s, Iterator *i);
void *set_iterate_skip(Set *s, void *value, Iterator *i);
void set_clear(Set *s);
+void set_clear_free(Set *s);
+
void *set_steal_first(Set *s);
void* set_first(Set *s);
void* set_last(Set *s);