Add strv_prepend
Inserts a copy of the value at the head of the list.
This commit is contained in:
parent
43e7dd70bc
commit
82443be506
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue