X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbasic%2Fstrv.c;h=4d3cce8260c3d78272f983fc9d61a2fc0c0af03d;hb=48327b6bd2b0b7bd2697ccc79dd26d160015af78;hp=baaa72e674dc98b3ca3126efc1e385019ef361d0;hpb=c60d32aa37fc0b10451b0d392d90b3b96eb88ebc;p=elogind.git diff --git a/src/basic/strv.c b/src/basic/strv.c index baaa72e67..4d3cce826 100644 --- a/src/basic/strv.c +++ b/src/basic/strv.c @@ -87,8 +87,7 @@ void strv_clear(char **l) { char **strv_free(char **l) { strv_clear(l); - free(l); - return NULL; + return mfree(l); } char **strv_free_erase(char **l) { @@ -431,8 +430,7 @@ char *strv_join_quoted(char **l) { return buf; oom: - free(buf); - return NULL; + return mfree(buf); } #endif // 0 @@ -574,9 +572,6 @@ int strv_extend_front(char ***l, const char *value) { /* Like strv_extend(), but prepends rather than appends the new entry */ - if (!value) - return 0; - n = strv_length(*l); /* Increase and overflow check. */ @@ -584,9 +579,12 @@ int strv_extend_front(char ***l, const char *value) { if (m < n) return -ENOMEM; - v = strdup(value); - if (!v) - return -ENOMEM; + if (value) { + v = strdup(value); + if (!v) + return -ENOMEM; + } else + v = NULL; c = realloc_multiply(*l, sizeof(char*), m); if (!c) { @@ -882,8 +880,7 @@ char ***strv_free_free(char ***l) { for (i = l; *i; i++) strv_free(*i); - free(l); - return NULL; + return mfree(l); } char **strv_skip(char **l, size_t n) {