strv: introduce string_strv_hashmap_remove()
This commit is contained in:
@@ -1063,6 +1063,23 @@ int fputstrv(FILE *f, char * const *l, const char *separator, bool *space) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void string_strv_hashmap_remove(Hashmap *h, const char *key, const char *value) {
|
||||
assert(key);
|
||||
|
||||
if (value) {
|
||||
char **l = hashmap_get(h, key);
|
||||
if (!l)
|
||||
return;
|
||||
|
||||
strv_remove(l, value);
|
||||
if (!strv_isempty(l))
|
||||
return;
|
||||
}
|
||||
|
||||
_unused_ _cleanup_free_ char *key_free = NULL;
|
||||
strv_free(hashmap_remove2(h, key, (void**) &key_free));
|
||||
}
|
||||
|
||||
static int string_strv_hashmap_put_internal(Hashmap *h, const char *key, const char *value) {
|
||||
char **l;
|
||||
int r;
|
||||
|
||||
@@ -258,6 +258,10 @@ int fputstrv(FILE *f, char * const *l, const char *separator, bool *space);
|
||||
#define strv_free_and_replace(a, b) \
|
||||
free_and_replace_full(a, b, strv_free)
|
||||
|
||||
void string_strv_hashmap_remove(Hashmap *h, const char *key, const char *value);
|
||||
static inline void string_strv_ordered_hashmap_remove(OrderedHashmap *h, const char *key, const char *value) {
|
||||
string_strv_hashmap_remove(PLAIN_HASHMAP(h), key, value);
|
||||
}
|
||||
int _string_strv_hashmap_put(Hashmap **h, const char *key, const char *value HASHMAP_DEBUG_PARAMS);
|
||||
int _string_strv_ordered_hashmap_put(OrderedHashmap **h, const char *key, const char *value HASHMAP_DEBUG_PARAMS);
|
||||
#define string_strv_hashmap_put(h, k, v) _string_strv_hashmap_put(h, k, v HASHMAP_DEBUG_SRC_ARGS)
|
||||
|
||||
Reference in New Issue
Block a user