]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/libudev/libudev-list.c
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / libudev / libudev-list.c
index 19e9130be0b630ac6445e584a66289c5b50cea3b..29fbdbd4509e7365875a8ef0f99b12c485b25c53 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <stdlib.h>
-#include <stddef.h>
 #include <errno.h>
+#include <stddef.h>
+#include <stdlib.h>
 #include <string.h>
 
+#include "alloc-util.h"
 #include "libudev-private.h"
 
 /**
@@ -165,17 +167,16 @@ struct udev_list_entry *udev_list_entry_add(struct udev_list *list, const char *
         entry = new0(struct udev_list_entry, 1);
         if (entry == NULL)
                 return NULL;
+
         entry->name = strdup(name);
-        if (entry->name == NULL) {
-                free(entry);
-                return NULL;
-        }
+        if (entry->name == NULL)
+                return mfree(entry);
+
         if (value != NULL) {
                 entry->value = strdup(value);
                 if (entry->value == NULL) {
                         free(entry->name);
-                        free(entry);
-                        return NULL;
+                        return mfree(entry);
                 }
         }
 
@@ -192,8 +193,7 @@ struct udev_list_entry *udev_list_entry_add(struct udev_list *list, const char *
                         if (entries == NULL) {
                                 free(entry->name);
                                 free(entry->value);
-                                free(entry);
-                                return NULL;
+                                return mfree(entry);
                         }
                         list->entries = entries;
                         list->entries_max += add;