summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/macro.h1
-rw-r--r--src/shared/set.c8
-rw-r--r--src/shared/set.h1
3 files changed, 10 insertions, 0 deletions
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 700171b832..29d91392f8 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -199,6 +199,7 @@ static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) {
#define _cleanup_close_ __attribute__((cleanup(closep)))
#define _cleanup_closedir_ __attribute__((cleanup(closedirp)))
#define _cleanup_umask_ __attribute__((cleanup(umaskp)))
+#define _cleanup_set_free_ __attribute__((cleanup(set_freep)))
#define _cleanup_strv_free_ __attribute__((cleanup(strv_freep)))
#define VA_FORMAT_ADVANCE(format, ap) \
diff --git a/src/shared/set.c b/src/shared/set.c
index 5f83c50839..53399b655b 100644
--- a/src/shared/set.c
+++ b/src/shared/set.c
@@ -37,6 +37,14 @@ void set_free(Set* s) {
hashmap_free(MAKE_HASHMAP(s));
}
+void set_freep(Set **s) {
+ if (!s)
+ return;
+
+ set_free(*s);
+ *s = NULL;
+}
+
void set_free_free(Set *s) {
hashmap_free_free(MAKE_HASHMAP(s));
}
diff --git a/src/shared/set.h b/src/shared/set.h
index 9162e2ae80..ed5b5a44d6 100644
--- a/src/shared/set.h
+++ b/src/shared/set.h
@@ -33,6 +33,7 @@ typedef struct Set Set;
Set *set_new(hash_func_t hash_func, compare_func_t compare_func);
void set_free(Set* s);
+void set_freep(Set **s);
void set_free_free(Set *s);
Set* set_copy(Set *s);
int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func);