]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/env-util.c
tree-wide: use mfree more
[thirdparty/systemd.git] / src / basic / env-util.c
index 9ddac5d6a1c39e967c576d6cd0de6356c5375879..b74290d6fd49ad721660c924c239d29f96cda990 100644 (file)
@@ -1,5 +1,3 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
 /***
   This file is part of systemd.
 
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
+#include <errno.h>
 #include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 #include "alloc-util.h"
-#include "def.h"
 #include "env-util.h"
+#include "extract-word.h"
+#include "macro.h"
 #include "parse-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "utf8.h"
-#include "util.h"
 
 #define VALID_CHARS_ENV_NAME                    \
         DIGITS LETTERS                          \
@@ -138,6 +140,21 @@ bool strv_env_is_valid(char **e) {
         return true;
 }
 
+bool strv_env_name_is_valid(char **l) {
+        char **p, **q;
+
+        STRV_FOREACH(p, l) {
+                if (!env_name_is_valid(*p))
+                        return false;
+
+                STRV_FOREACH(q, p + 1)
+                        if (streq(*p, *q))
+                                return false;
+        }
+
+        return true;
+}
+
 bool strv_env_name_or_assignment_is_valid(char **l) {
         char **p, **q;
 
@@ -527,8 +544,7 @@ char *replace_env(const char *format, char **env) {
         return k;
 
 fail:
-        free(r);
-        return NULL;
+        return mfree(r);
 }
 
 char **replace_env_argv(char **argv, char **env) {