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/journal/catalog.c | 3 +-- src/journal/coredumpctl.c | 3 +-- src/journal/journalctl.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'src/journal') diff --git a/src/journal/catalog.c b/src/journal/catalog.c index 33b0539315..a3e51e2f52 100644 --- a/src/journal/catalog.c +++ b/src/journal/catalog.c @@ -263,8 +263,7 @@ int catalog_import_file(Hashmap *h, struct strbuf *sb, const char *path) { if (r < 0) return r; - free(lang); - lang = NULL; + lang = mfree(lang); } if (with_language) { diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c index fc49b2e174..098f62af50 100644 --- a/src/journal/coredumpctl.c +++ b/src/journal/coredumpctl.c @@ -587,8 +587,7 @@ static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) { if (filename && access(filename, R_OK) < 0) { log_full(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, "File %s is not readable: %m", filename); - free(filename); - filename = NULL; + filename = mfree(filename); } if (filename && !endswith(filename, ".xz") && !endswith(filename, ".lz4")) { diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 073cc77711..355c4f1ee3 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1259,8 +1259,7 @@ static int add_units(sd_journal *j) { } } - strv_free(patterns); - patterns = NULL; + patterns = strv_free(patterns); STRV_FOREACH(i, arg_user_units) { _cleanup_free_ char *u = NULL; -- cgit v1.2.3-54-g00ecf