From: Lennart Poettering Date: Mon, 7 May 2018 16:18:11 +0000 (+0200) Subject: conf-parser: shorten config_parse_string() by using free_and_strdup() and empty_to_null() X-Git-Tag: v239~243^2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a4ff98840fba01f9eb1bed23846ae8d1ca796b5;p=thirdparty%2Fsystemd.git conf-parser: shorten config_parse_string() by using free_and_strdup() and empty_to_null() --- diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 7e5fba4330c..84d0c16996e 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; }