X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbasic%2Fset.h;h=170f0c44692296bb22d5b90fce9c9744d8c1b0cd;hb=479020f14217990e24e588bf26d9826b18b64d8c;hp=87cfcd8e42c36e8dd6e7735d3b2d445e532f78de;hpb=5db0e7adf018c82dd63cd21d31dd313dff5561af;p=elogind.git diff --git a/src/basic/set.h b/src/basic/set.h index 87cfcd8e4..170f0c446 100644 --- a/src/basic/set.h +++ b/src/basic/set.h @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - #pragma once /*** @@ -27,13 +25,14 @@ Set *internal_set_new(const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS); #define set_new(ops) internal_set_new(ops HASHMAP_DEBUG_SRC_ARGS) - -static inline void set_free(Set *s) { +static inline Set *set_free(Set *s) { internal_hashmap_free(HASHMAP_BASE(s)); + return NULL; } -static inline void set_free_free(Set *s) { +static inline Set *set_free_free(Set *s) { internal_hashmap_free_free(HASHMAP_BASE(s)); + return NULL; } /* no set_free_free_free */ @@ -63,7 +62,9 @@ static inline void *set_remove(Set *s, const void *key) { /* no set_remove2 */ /* no set_remove_value */ -// UNNEEDED int set_remove_and_put(Set *s, const void *old_key, const void *new_key); +#if 0 /// UNNEEDED by elogind +int set_remove_and_put(Set *s, const void *old_key, const void *new_key); +#endif // 0 /* no set_remove_and_replace */ int set_merge(Set *s, Set *other); @@ -122,11 +123,16 @@ static inline char **set_get_strv(Set *s) { int set_consume(Set *s, void *value); int set_put_strdup(Set *s, const char *p); -// UNNEEDED int set_put_strdupv(Set *s, char **l); +#if 0 /// UNNEEDED by elogind +int set_put_strdupv(Set *s, char **l); +#endif // 0 #define SET_FOREACH(e, s, i) \ for ((i) = ITERATOR_FIRST; set_iterate((s), &(i), (void**)&(e)); ) +#define SET_FOREACH_MOVE(e, d, s) \ + for (; ({ e = set_first(s); assert_se(!e || set_move_one(d, s, e) >= 0); e; }); ) + DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, set_free); DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, set_free_free);