summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/strv.c15
-rw-r--r--src/shared/strv.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/src/shared/strv.c b/src/shared/strv.c
index 67706dc381..1ef0b26a25 100644
--- a/src/shared/strv.c
+++ b/src/shared/strv.c
@@ -527,3 +527,18 @@ void strv_print(char **l) {
STRV_FOREACH(s, l)
puts(*s);
}
+
+int strv_extendf(char ***l, const char *format, ...) {
+ va_list ap;
+ char *x;
+ int r;
+
+ va_start(ap, format);
+ r = vasprintf(&x, format, ap);
+ va_end(ap);
+
+ if (r < 0)
+ return -ENOMEM;
+
+ return strv_consume(l, x);
+}
diff --git a/src/shared/strv.h b/src/shared/strv.h
index 618951c5e3..2dc2bc6c49 100644
--- a/src/shared/strv.h
+++ b/src/shared/strv.h
@@ -39,6 +39,7 @@ unsigned strv_length(char * const *l) _pure_;
int strv_extend_strv(char ***a, char **b);
int strv_extend_strv_concat(char ***a, char **b, const char *suffix);
int strv_extend(char ***l, const char *value);
+int strv_extendf(char ***l, const char *format, ...);
int strv_push(char ***l, char *value);
int strv_consume(char ***l, char *value);