X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fset.h;h=51e40d3a6c506c9ccfce9a51bb9587c2483807c4;hb=b733fbe7a0214eb43e402db7179697bf9c0975c1;hp=4605ecd2c17caedb7465ea22b8ec265a5cb6d5bc;hpb=89439d4fc0d29f04ac68432fd06ab84bc4e36e20;p=elogind.git diff --git a/src/shared/set.h b/src/shared/set.h index 4605ecd2c..51e40d3a6 100644 --- a/src/shared/set.h +++ b/src/shared/set.h @@ -22,7 +22,7 @@ ***/ #include "hashmap.h" -#include "util.h" +#include "macro.h" 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) @@ -57,7 +57,7 @@ static inline bool set_contains(Set *s, const void *key) { return internal_hashmap_contains(HASHMAP_BASE(s), key); } -static inline void *set_remove(Set *s, void *key) { +static inline void *set_remove(Set *s, const void *key) { return internal_hashmap_remove(HASHMAP_BASE(s), key); } @@ -91,7 +91,7 @@ static inline unsigned set_buckets(Set *s) { return internal_hashmap_buckets(HASHMAP_BASE(s)); } -void *set_iterate(Set *s, Iterator *i); +bool set_iterate(Set *s, Iterator *i, void **value); static inline void set_clear(Set *s) { internal_hashmap_clear(HASHMAP_BASE(s)); @@ -125,7 +125,7 @@ int set_put_strdup(Set *s, const char *p); int set_put_strdupv(Set *s, char **l); #define SET_FOREACH(e, s, i) \ - for ((i) = ITERATOR_FIRST, (e) = set_iterate((s), &(i)); (e); (e) = set_iterate((s), &(i))) + for ((i) = ITERATOR_FIRST; set_iterate((s), &(i), (void**)&(e)); ) DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, set_free); DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, set_free_free);