summaryrefslogtreecommitdiff
path: root/src/basic/set.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic/set.h')
-rw-r--r--src/basic/set.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/basic/set.h b/src/basic/set.h
index 08b7c4a72..b424f3423 100644
--- a/src/basic/set.h
+++ b/src/basic/set.h
@@ -109,6 +109,18 @@ static inline void *set_steal_first(Set *s) {
return internal_hashmap_steal_first(HASHMAP_BASE(s));
}
+#define set_clear_with_destructor(_s, _f) \
+ ({ \
+ void *_item; \
+ while ((_item = set_steal_first(_s))) \
+ _f(_item); \
+ })
+#define set_free_with_destructor(_s, _f) \
+ ({ \
+ set_clear_with_destructor(_s, _f); \
+ set_free(_s); \
+ })
+
/* no set_steal_first_key */
/* no set_first_key */