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-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=fc7062176374472f32624f73819188ddab30e411;p=elogind.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 d570a7068..d01f604de 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -38,6 +38,7 @@ #include "def.h" #include "fileio.h" //#include "rlimit-util.h" +//#include "rlimit-util.h" int config_item_table_lookup( const void *table, @@ -722,7 +723,7 @@ int config_parse_string( void *data, void *userdata) { - char **s = data, *n; + char **s = data; assert(filename); assert(lvalue); @@ -734,16 +735,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; }