chiark / gitweb /
conf-parser: shorten config_parse_string() by using free_and_strdup() and empty_to_null()
authorLennart Poettering <lennart@poettering.net>
Mon, 7 May 2018 16:18:11 +0000 (18:18 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
src/shared/conf-parser.c

index d570a7068938c28989441779cd331d3caad2b9fd..d01f604de36b13ffdf696a468bcd6105fa6637b7 100644 (file)
@@ -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;
 }