From: Lennart Poettering Date: Tue, 16 Jan 2024 18:17:12 +0000 (+0100) Subject: strv: remove strv_extend_front() X-Git-Tag: v256-rc1~1126^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b9d37112f2f078d09d913c9716ac0555a5b9e37d;p=thirdparty%2Fsystemd.git strv: remove strv_extend_front() It's entirely identical to strv_push_prepend() hence drop the duplicate definition. --- diff --git a/src/basic/strv.c b/src/basic/strv.c index 27a70a84158..97da11e1644 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -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 */ diff --git a/src/basic/strv.h b/src/basic/strv.h index 7361faed84c..f6502e50ef0 100644 --- a/src/basic/strv.h +++ b/src/basic/strv.h @@ -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) { diff --git a/src/environment-d-generator/environment-d-generator.c b/src/environment-d-generator/environment-d-generator.c index 90e31c98efa..fa2c54af31d 100644 --- a/src/environment-d-generator/environment-d-generator.c +++ b/src/environment-d-generator/environment-d-generator.c @@ -26,7 +26,7 @@ static int environment_dirs(char ***ret) { if (r < 0) return r; - r = strv_extend_front(&dirs, c); + r = strv_consume_prepend(&dirs, TAKE_PTR(c)); if (r < 0) return r;