chiark / gitweb /
conf-parse: use free_and_replace()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 3 Jun 2018 15:30:36 +0000 (00:30 +0900)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
Also removes unnecessary empty lines.

src/shared/conf-parser.c

index 32d26c36dbbe91e7f4f76d8919fbfc4d54fc00d8..96bcddb4fcf85ffcefac3024be4b4ee0d3c70bfe 100644 (file)
@@ -44,6 +44,7 @@
 //#include "rlimit-util.h"
 //#include "rlimit-util.h"
 //#include "rlimit-util.h"
+//#include "rlimit-util.h"
 
 int config_item_table_lookup(
                 const void *table,
@@ -250,8 +251,7 @@ static int parse_line(
                         *section_line = 0;
                         *section_ignored = true;
                 } else {
-                        free(*section);
-                        *section = n;
+                        free_and_replace(*section, n);
                         *section_line = line;
                         *section_ignored = false;
                 }
@@ -409,7 +409,6 @@ int config_parse(const char *unit,
                         if (flags & CONFIG_PARSE_WARN)
                                 log_warning_errno(r, "%s:%u: Failed to parse file: %m", filename, line);
                         return r;
-
                 }
 
                 continuation = mfree(continuation);
@@ -432,7 +431,6 @@ int config_parse(const char *unit,
                         if (flags & CONFIG_PARSE_WARN)
                                 log_warning_errno(r, "%s:%u: Failed to parse file: %m", filename, line);
                         return r;
-
                 }
         }