chiark / gitweb /
env-util,fileio: immediately replace variables in load_env_file_push()
[elogind.git] / src / basic / strv.c
index baaa72e674dc98b3ca3126efc1e385019ef361d0..4d3cce8260c3d78272f983fc9d61a2fc0c0af03d 100644 (file)
@@ -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) {