Add strv_prepend

Inserts a copy of the value at the head of the list.
This commit is contained in:
williamvds
2020-10-21 17:14:37 +01:00
parent 43e7dd70bc
commit 82443be506
2 changed files with 14 additions and 0 deletions
+13
View File
@@ -537,6 +537,19 @@ int strv_consume_prepend(char ***l, char *value) {
return r;
}
int strv_prepend(char ***l, const char *value) {
char *v;
if (!value)
return 0;
v = strdup(value);
if (!v)
return -ENOMEM;
return strv_consume_prepend(l, v);
}
int strv_extend(char ***l, const char *value) {
char *v;