aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/strv.c')
-rw-r--r--src/shared/strv.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/shared/strv.c b/src/shared/strv.c
index 1ef0b26a2..b4c476eff 100644
--- a/src/shared/strv.c
+++ b/src/shared/strv.c
@@ -378,6 +378,30 @@ int strv_push(char ***l, char *value) {
return 0;
}
+int strv_push_prepend(char ***l, char *value) {
+ char **c;
+ unsigned n, i;
+
+ if (!value)
+ return 0;
+
+ n = strv_length(*l);
+ c = new(char*, n + 2);
+ if (!c)
+ return -ENOMEM;
+
+ for (i = 0; i < n; i++)
+ c[i+1] = (*l)[i];
+
+ c[0] = value;
+ c[n+1] = NULL;
+
+ free(*l);
+ *l = c;
+
+ return 0;
+}
+
int strv_consume(char ***l, char *value) {
int r;
@@ -388,6 +412,16 @@ int strv_consume(char ***l, char *value) {
return r;
}
+int strv_consume_prepend(char ***l, char *value) {
+ int r;
+
+ r = strv_push_prepend(l, value);
+ if (r < 0)
+ free(value);
+
+ return r;
+}
+
int strv_extend(char ***l, const char *value) {
char *v;