]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/test/test-hostname-util.c
util-lib: split our string related calls from util.[ch] into its own file string...
[thirdparty/systemd.git] / src / test / test-hostname-util.c
index 08be3f7bf2fdc911bce7ed3b8dc1de5e7f982c79..ac8f4ecc6868a73fca3d576ed2a2f614eb89392c 100644 (file)
@@ -24,6 +24,7 @@
 #include "util.h"
 #include "fileio.h"
 #include "hostname-util.h"
+#include "string-util.h"
 
 static void test_hostname_is_valid(void) {
         assert_se(hostname_is_valid("foobar", false));
@@ -111,32 +112,28 @@ static void test_read_hostname_config(void) {
         write_string_file(path, "foo", WRITE_STRING_FILE_CREATE);
         assert_se(read_hostname_config(path, &hostname) == 0);
         assert_se(streq(hostname, "foo"));
-        free(hostname);
-        hostname = NULL;
+        hostname = mfree(hostname);
 
         /* with comment */
         write_string_file(path, "# comment\nfoo", WRITE_STRING_FILE_CREATE);
         assert_se(read_hostname_config(path, &hostname) == 0);
         assert_se(hostname);
         assert_se(streq(hostname, "foo"));
-        free(hostname);
-        hostname = NULL;
+        hostname = mfree(hostname);
 
         /* with comment and extra whitespace */
         write_string_file(path, "# comment\n\n foo ", WRITE_STRING_FILE_CREATE);
         assert_se(read_hostname_config(path, &hostname) == 0);
         assert_se(hostname);
         assert_se(streq(hostname, "foo"));
-        free(hostname);
-        hostname = NULL;
+        hostname = mfree(hostname);
 
         /* cleans up name */
         write_string_file(path, "!foo/bar.com", WRITE_STRING_FILE_CREATE);
         assert_se(read_hostname_config(path, &hostname) == 0);
         assert_se(hostname);
         assert_se(streq(hostname, "foobar.com"));
-        free(hostname);
-        hostname = NULL;
+        hostname = mfree(hostname);
 
         /* no value set */
         hostname = (char*) 0x1234;