summaryrefslogtreecommitdiff
path: root/src/strv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/strv.c')
-rw-r--r--src/strv.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/strv.c b/src/strv.c
index 85599fe92c..01464e1e33 100644
--- a/src/strv.c
+++ b/src/strv.c
@@ -511,3 +511,31 @@ char **strv_env_delete(char **x, unsigned n_lists, ...) {
return r;
}
+
+char **strv_env_set(char **x, const char *p) {
+
+ char **k, **r;
+
+ if (!(r = new(char*, strv_length(x)+2)))
+ return NULL;
+
+ k = r;
+ if (env_append(r, &k, x) < 0)
+ goto fail;
+
+ if (!(*(k++) = strdup(p)))
+ goto fail;
+
+ *k = NULL;
+
+ return r;
+
+fail:
+ for (k--; k >= r; k--)
+ free(*k);
+
+ free(r);
+
+ return NULL;
+
+}