From 97b11eedff9d2e17101ad453caf9e48b73246719 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Fri, 31 Jul 2015 19:56:38 +0200 Subject: tree-wide: introduce mfree() Pretty trivial helper which wraps free() but returns NULL, so we can simplify this: free(foobar); foobar = NULL; to this: foobar = mfree(foobar); --- src/core/load-fragment.c | 8 ++------ src/core/main.c | 6 ++---- src/core/snapshot.c | 3 +-- 3 files changed, 5 insertions(+), 12 deletions(-) (limited to 'src/core') diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index a48cb4029a..ba73cc410e 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -3508,9 +3508,7 @@ static int load_from_path(Unit *u, const char *path) { r = open_follow(&filename, &f, symlink_names, &id); if (r < 0) { - free(filename); - filename = NULL; - + filename = mfree(filename); if (r != -ENOENT) return r; } @@ -3534,9 +3532,7 @@ static int load_from_path(Unit *u, const char *path) { r = open_follow(&filename, &f, symlink_names, &id); if (r < 0) { - free(filename); - filename = NULL; - + filename = mfree(filename); if (r != -ENOENT) return r; diff --git a/src/core/main.c b/src/core/main.c index 6ae8b51544..a66fb18418 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1844,13 +1844,11 @@ finish: arg_default_rlimit[j] = NULL; } - free(arg_default_unit); - arg_default_unit = NULL; + arg_default_unit = mfree(arg_default_unit); free_join_controllers(); - strv_free(arg_default_environment); - arg_default_environment = NULL; + arg_default_environment = strv_free(arg_default_environment); set_free(arg_syscall_archs); arg_syscall_archs = NULL; diff --git a/src/core/snapshot.c b/src/core/snapshot.c index 1e634b9bc1..9518e21f36 100644 --- a/src/core/snapshot.c +++ b/src/core/snapshot.c @@ -217,8 +217,7 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, sd_bus_error *e, break; } - free(n); - n = NULL; + n = mfree(n); } } -- cgit v1.2.3-54-g00ecf