chiark / gitweb /
shared: introduce _cleanup_set_free_free_
[elogind.git] / src / shared / set.c
index f5c7c37cab81922b6cdda91a0ed1df8654746ff1..cd910d70abbc403eb54ae8eb50871c36f93929d6 100644 (file)
@@ -37,10 +37,26 @@ 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));
 }
 
+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);
 }
@@ -57,6 +73,10 @@ void *set_get(Set *s, void *value) {
         return hashmap_get(MAKE_HASHMAP(s), value);
 }
 
+bool set_contains(Set *s, void *value) {
+        return hashmap_contains(MAKE_HASHMAP(s), value);
+}
+
 void *set_remove(Set *s, void *value) {
         return hashmap_remove(MAKE_HASHMAP(s), value);
 }
@@ -120,3 +140,7 @@ void set_clear(Set *s) {
 void set_clear_free(Set *s) {
         hashmap_clear_free(MAKE_HASHMAP(s));
 }
+
+char **set_get_strv(Set *s) {
+        return hashmap_get_strv(MAKE_HASHMAP(s));
+}