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
No known key found for this signature in database
GPG Key ID: 7A4DF5A8CDBD49C7
2 changed files with 14 additions and 0 deletions

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;

View File

@ -34,6 +34,7 @@ size_t strv_length(char * const *l) _pure_;
int strv_extend_strv(char ***a, char * const *b, bool filter_duplicates);
int strv_extend_strv_concat(char ***a, char * const *b, const char *suffix);
int strv_prepend(char ***l, const char *value);
int strv_extend(char ***l, const char *value);
int strv_extendf(char ***l, const char *format, ...) _printf_(2,0);
int strv_extend_front(char ***l, const char *value);