chiark / gitweb /
shared: introduce _cleanup_set_free_free_
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 29 Jan 2013 00:36:48 +0000 (19:36 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 30 Jan 2013 00:01:41 +0000 (19:01 -0500)
src/shared/macro.h
src/shared/set.c
src/shared/set.h

index b307dedaa8bd6fc5fa379f5b715e6e97df7eaa0e..055919048c90d8c203baf1ae1d8913d2c002714a 100644 (file)
@@ -201,6 +201,7 @@ static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) {
 #define _cleanup_closedir_ __attribute__((cleanup(closedirp)))
 #define _cleanup_umask_ __attribute__((cleanup(umaskp)))
 #define _cleanup_set_free_ __attribute__((cleanup(set_freep)))
 #define _cleanup_closedir_ __attribute__((cleanup(closedirp)))
 #define _cleanup_umask_ __attribute__((cleanup(umaskp)))
 #define _cleanup_set_free_ __attribute__((cleanup(set_freep)))
+#define _cleanup_set_free_free_ __attribute__((cleanup(set_free_freep)))
 #define _cleanup_strv_free_ __attribute__((cleanup(strv_freep)))
 
 #define VA_FORMAT_ADVANCE(format, ap)                                   \
 #define _cleanup_strv_free_ __attribute__((cleanup(strv_freep)))
 
 #define VA_FORMAT_ADVANCE(format, ap)                                   \
index 53399b655b43daafe615489cdbadac8e9dfe17e9..cd910d70abbc403eb54ae8eb50871c36f93929d6 100644 (file)
@@ -49,6 +49,14 @@ void set_free_free(Set *s) {
         hashmap_free_free(MAKE_HASHMAP(s));
 }
 
         hashmap_free_free(MAKE_HASHMAP(s));
 }
 
+void set_free_freep(Set **s) {
+        if (!*s)
+                return;
+
+        set_free_free(*s);
+        *s = NULL;
+}
+
 int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func) {
         return hashmap_ensure_allocated((Hashmap**) s, hash_func, compare_func);
 }
 int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func) {
         return hashmap_ensure_allocated((Hashmap**) s, hash_func, compare_func);
 }
index ed5b5a44d6456e372281f1f7522e345c0e3fc0ad..2f792585faea545d426c0cdce023a44b0f5adba4 100644 (file)
@@ -35,6 +35,7 @@ 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);
 void set_free(Set* s);
 void set_freep(Set **s);
 void set_free_free(Set *s);
+void set_free_freep(Set **s);
 Set* set_copy(Set *s);
 int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func);
 
 Set* set_copy(Set *s);
 int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func);