[systemd-commits] 3 commits - src/shared src/udev

Tom Gundersen tomegun at kemper.freedesktop.org
Tue Dec 16 16:11:59 PST 2014


 src/shared/path-util.c                 |    1 +
 src/shared/strv.c                      |    7 ++++++-
 src/shared/strv.h                      |    2 ++
 src/udev/udev-builtin-net_setup_link.c |    2 +-
 4 files changed, 10 insertions(+), 2 deletions(-)

New commits:
commit dd9c7723fafc8b326188efa86efe00bcbe5abcfd
Author: Tom Gundersen <teg at jklm.no>
Date:   Wed Dec 17 01:08:56 2014 +0100

    shared: strv - add strv_clear()
    
    This frees the elements of the strv without freeing the strv itself.

diff --git a/src/shared/strv.c b/src/shared/strv.c
index fdb658c..f86ddda 100644
--- a/src/shared/strv.c
+++ b/src/shared/strv.c
@@ -69,7 +69,7 @@ char *strv_find_startswith(char **l, const char *name) {
         return NULL;
 }
 
-void strv_free(char **l) {
+void strv_clear(char **l) {
         char **k;
 
         if (!l)
@@ -78,6 +78,11 @@ void strv_free(char **l) {
         for (k = l; *k; k++)
                 free(*k);
 
+        *l = NULL;
+}
+
+void strv_free(char **l) {
+        strv_clear(l);
         free(l);
 }
 
diff --git a/src/shared/strv.h b/src/shared/strv.h
index 2c0280b..9e5b1bb 100644
--- a/src/shared/strv.h
+++ b/src/shared/strv.h
@@ -34,6 +34,8 @@ void strv_free(char **l);
 DEFINE_TRIVIAL_CLEANUP_FUNC(char**, strv_free);
 #define _cleanup_strv_free_ _cleanup_(strv_freep)
 
+void strv_clear(char **l);
+
 char **strv_copy(char * const *l);
 unsigned strv_length(char * const *l) _pure_;
 

commit 3542eac7f98e74ca106ac6df81b3b3cb158b35be
Author: Tom Gundersen <teg at jklm.no>
Date:   Tue Dec 16 22:24:54 2014 +0100

    shared: path-util - memory leak

diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index dcc8321..3256dee 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -306,6 +306,7 @@ char **path_strv_resolve(char **l, const char *prefix) {
                         } else {
                                 /* canonicalized path goes outside of
                                  * prefix, keep the original path instead */
+                                free(u);
                                 u = orig;
                                 orig = NULL;
                         }

commit c487c9cec012282273e16f3110734309934a1281
Author: Tom Gundersen <teg at jklm.no>
Date:   Tue Dec 16 21:49:06 2014 +0100

    udev: net_setup - fix warning

diff --git a/src/udev/udev-builtin-net_setup_link.c b/src/udev/udev-builtin-net_setup_link.c
index 87d10bf..55b6241 100644
--- a/src/udev/udev-builtin-net_setup_link.c
+++ b/src/udev/udev-builtin-net_setup_link.c
@@ -27,7 +27,7 @@ static link_config_ctx *ctx = NULL;
 
 static int builtin_net_setup_link(struct udev_device *dev, int argc, char **argv, bool test) {
         _cleanup_free_ char *driver = NULL;
-        const char *name;
+        const char *name = NULL;
         link_config *link;
         int r;
 



More information about the systemd-commits mailing list