strv: introduce strv_extend_joined() and strv_extend_joined_with_size()

This commit is contained in:
Yu Watanabe
2025-11-01 00:59:36 +09:00
parent 69350ee3e3
commit 19bbcd35d7
3 changed files with 40 additions and 0 deletions
+12
View File
@@ -921,6 +921,18 @@ int strv_extendf_with_size(char ***l, size_t *n, const char *format, ...) {
return strv_consume_with_size(l, n, x);
}
int strv_extend_joined_with_size_sentinel(char ***l, size_t *n, ...) {
va_list ap;
va_start(ap, n);
char *x = strextendv_with_separator(/* x= */ NULL, /* separator=*/ NULL, ap);
va_end(ap);
if (!x)
return -ENOMEM;
return strv_consume_with_size(l, n, x);
}
char* startswith_strv(const char *s, char * const *l) {
STRV_FOREACH(i, l) {
char *found = startswith(s, *i);