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.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/basic/set.h b/src/basic/set.h
index 12d0fda1ca..156ab4b081 100644
--- a/src/basic/set.h
+++ b/src/basic/set.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
/***
@@ -107,6 +108,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 */