diff options
Diffstat (limited to 'src/libudev/strv.c')
-rw-r--r-- | src/libudev/strv.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/libudev/strv.c b/src/libudev/strv.c index cbfe2388d6..da8ea8a0a6 100644 --- a/src/libudev/strv.c +++ b/src/libudev/strv.c @@ -161,9 +161,18 @@ int strv_push(char ***l, char *value) { return 0; } +int strv_consume(char ***l, char *value) { + int r; + + r = strv_push(l, value); + if (r < 0) + free(value); + + return r; +} + int strv_extend(char ***l, const char *value) { char *v; - int r; if (!value) return 0; @@ -172,11 +181,7 @@ int strv_extend(char ***l, const char *value) { if (!v) return -ENOMEM; - r = strv_push(l, v); - if (r < 0) - free(v); - - return r; + return strv_consume(l, v); } char **strv_uniq(char **l) { |