mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 00:47:10 +09:00
strv: introduce strv_extend_joined() and strv_extend_joined_with_size()
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -59,6 +59,10 @@ int strv_extend_many_internal(char ***l, const char *value, ...);
|
||||
int strv_extendf_with_size(char ***l, size_t *n, const char *format, ...) _printf_(3,4);
|
||||
#define strv_extendf(l, ...) strv_extendf_with_size(l, NULL, __VA_ARGS__)
|
||||
|
||||
int strv_extend_joined_with_size_sentinel(char ***l, size_t *n, ...) _sentinel_;
|
||||
#define strv_extend_joined_with_size(l, n, ...) strv_extend_joined_with_size_sentinel(l, n, __VA_ARGS__, NULL)
|
||||
#define strv_extend_joined(l, ...) strv_extend_joined_with_size(l, NULL, __VA_ARGS__)
|
||||
|
||||
int strv_push_with_size(char ***l, size_t *n, char *value);
|
||||
static inline int strv_push(char ***l, char *value) {
|
||||
return strv_push_with_size(l, NULL, value);
|
||||
|
||||
Reference in New Issue
Block a user