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 a5ce7e9593..3e7778d61c 100644
--- a/src/shared/strv.c
+++ b/src/shared/strv.c
@@ -387,6 +387,21 @@ fail:
return NULL;
}
+char **strv_appendf(char **l, const char *format, ...) {
+ va_list ap;
+ _cleanup_free_ char *s = NULL;
+ int r;
+
+ va_start(ap, format);
+ r = vasprintf(&s, format, ap);
+ va_end(ap);
+
+ if (r < 0)
+ return NULL;
+
+ return strv_append(l, s);
+}
+
int strv_push(char ***l, char *value) {
char **c;
unsigned n;
diff --git a/src/shared/strv.h b/src/shared/strv.h
index e35118752f..4ade827a42 100644
--- a/src/shared/strv.h
+++ b/src/shared/strv.h
@@ -42,6 +42,7 @@ unsigned strv_length(char * const *l) _pure_;
char **strv_merge(char **a, char **b);
char **strv_merge_concat(char **a, char **b, const char *suffix);
char **strv_append(char **l, const char *s);
+char **strv_appendf(char **l, const char *format, ...) _printf_attr_(2, 3);
int strv_extend(char ***l, const char *value);
int strv_push(char ***l, char *value);