diff options
-rw-r--r-- | strv.c | 10 | ||||
-rw-r--r-- | strv.h | 4 |
2 files changed, 13 insertions, 1 deletions
@@ -145,3 +145,13 @@ fail: return NULL; } + +bool strv_contains(char **l, const char *s) { + char **i; + + STRV_FOREACH(i, l) + if (streq(*i, s)) + return true; + + return false; +} @@ -12,10 +12,12 @@ unsigned strv_length(char **l); char **strv_merge(char **a, char **b); +bool strv_contains(char **l, const char *s); + char **strv_new(const char *x, ...) __sentinel; #define STRV_FOREACH(s, l) \ - for ((s) = (l); (l) && *(s); (s)++) + for ((s) = (l); (s) && *(s); (s)++) #define STRV_FOREACH_BACKWARDS(s, l) \ for (; (l) && ((s) >= (l)); (s)--) |