X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Fset.c;h=cd910d70abbc403eb54ae8eb50871c36f93929d6;hp=f5c7c37cab81922b6cdda91a0ed1df8654746ff1;hb=e3ded78be7df143ba780dd55ca8897fdddd67460;hpb=9946996cda11a18b44d82344676e5a0e96339408 diff --git a/src/shared/set.c b/src/shared/set.c index f5c7c37ca..cd910d70a 100644 --- a/src/shared/set.c +++ b/src/shared/set.c @@ -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)); +}