strv: add strv_remove_strv()

This is to strv_remove() what strv_extend_strv() is to strv_extend()
This commit is contained in:
Lennart Poettering
2026-06-01 10:56:15 +02:00
parent 8ff7a5cd09
commit 8b9d503471
3 changed files with 34 additions and 4 deletions
+13 -4
View File
@@ -812,16 +812,14 @@ bool strv_is_uniq(char * const *l) {
}
char** strv_remove(char **l, const char *s) {
char **f, **t;
if (!l)
return NULL;
assert(s);
/* Drops every occurrence of s in the string list, edits
* in-place. */
/* Drops every occurrence of s in the string list, edits in-place. */
char **f, **t;
for (f = t = l; *f; f++)
if (streq(*f, s))
free(*f);
@@ -832,6 +830,17 @@ char** strv_remove(char **l, const char *s) {
return l;
}
char** strv_remove_strv(char **l, char *const*ll) {
if (strv_isempty(l))
return l;
STRV_FOREACH(i, ll)
strv_remove(l, *i);
return l;
}
bool strv_overlap(char * const *a, char * const *b) {
POINTER_MAY_BE_NULL(a);
POINTER_MAY_BE_NULL(b);
+1
View File
@@ -85,6 +85,7 @@ int strv_consume_pair(char ***l, char *a, char *b);
int strv_consume_prepend(char ***l, char *value);
char** strv_remove(char **l, const char *s);
char** strv_remove_strv(char **l, char *const*ll);
char** strv_uniq(char **l);
bool strv_is_uniq(char * const *l) _pure_;