X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbasic%2Fset.h;h=70c462a1a2cc1bc8bfdec4ed7ad2b8930d338d68;hp=32daa05f79bf071a6bcb214af3050caf550f5919;hb=4a7059686430f596810f0c83e4897154828fd352;hpb=3b22396a4b2767a98172f6915929c47738cb0a1e diff --git a/src/basic/set.h b/src/basic/set.h index 32daa05f7..70c462a1a 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 /*** @@ -24,9 +22,8 @@ #include "hashmap.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) - +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 Set *set_free(Set *s) { internal_hashmap_free(HASHMAP_BASE(s)); @@ -44,8 +41,8 @@ static inline Set *set_copy(Set *s) { return (Set*) internal_hashmap_copy(HASHMAP_BASE(s)); } -int internal_set_ensure_allocated(Set **s, const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS); -#define set_ensure_allocated(h, ops) internal_set_ensure_allocated(h, ops HASHMAP_DEBUG_SRC_ARGS) +int internal_set_ensure_allocated(Set **s, const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS); +#define set_ensure_allocated(h, ops) internal_set_ensure_allocated(h, ops HASHMAP_DEBUG_SRC_ARGS) int set_put(Set *s, const void *key); /* no set_update */ @@ -65,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); @@ -124,11 +123,17 @@ 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); +int set_put_strsplit(Set *s, const char *v, const char *separators, ExtractFlags flags); +#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);