strv: remove strv_extend_front()

It's entirely identical to strv_push_prepend() hence drop the duplicate
definition.
This commit is contained in:
Lennart Poettering
2024-01-17 11:32:11 +01:00
parent a43431067e
commit b9d37112f2
3 changed files with 1 additions and 38 deletions
-36
View File
@@ -590,42 +590,6 @@ int strv_extend_with_size(char ***l, size_t *n, const char *value) {
return strv_consume_with_size(l, n, v);
}
int strv_extend_front(char ***l, const char *value) {
size_t n, m;
char *v, **c;
assert(l);
/* Like strv_extend(), but prepends rather than appends the new entry */
if (!value)
return 0;
n = strv_length(*l);
/* Increase and overflow check. */
m = n + 2;
if (m < n)
return -ENOMEM;
v = strdup(value);
if (!v)
return -ENOMEM;
c = reallocarray(*l, m, sizeof(char*));
if (!c) {
free(v);
return -ENOMEM;
}
memmove(c+1, c, n * sizeof(char*));
c[0] = v;
c[n+1] = NULL;
*l = c;
return 0;
}
char** strv_uniq(char **l) {
/* Drops duplicate entries. The first identical string will be
* kept, the others dropped */
-1
View File
@@ -56,7 +56,6 @@ static inline int strv_extend(char ***l, const char *value) {
}
int strv_extendf(char ***l, const char *format, ...) _printf_(2,3);
int strv_extend_front(char ***l, const char *value);
int strv_push_with_size(char ***l, size_t *n, char *value);
static inline int strv_push(char ***l, char *value) {