From 5a4ff98840fba01f9eb1bed23846ae8d1ca796b5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 7 May 2018 18:18:11 +0200 Subject: [PATCH] conf-parser: shorten config_parse_string() by using free_and_strdup() and empty_to_null() --- src/shared/conf-parser.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 7e5fba4..84d0c16 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -708,7 +708,7 @@ int config_parse_string( void *data, void *userdata) { - char **s = data, *n; + char **s = data; assert(filename); assert(lvalue); @@ -720,16 +720,8 @@ int config_parse_string( return 0; } - if (isempty(rvalue)) - n = NULL; - else { - n = strdup(rvalue); - if (!n) - return log_oom(); - } - - free(*s); - *s = n; + if (free_and_strdup(s, empty_to_null(rvalue)) < 0) + return log_oom(); return 0; } -- 2.7.4