diff options
author | Daniel Mack <github@zonque.org> | 2015-07-31 20:17:33 +0200 |
---|---|---|
committer | Daniel Mack <github@zonque.org> | 2015-07-31 20:17:33 +0200 |
commit | 6f7897f9d2bd5ec7d6a9be8ad700661bb17a21cf (patch) | |
tree | f03d3e452e8433c350616f6ffc7d28b08bd23335 /src/test | |
parent | 97d09a62836e1c6f807837cf47e83c970cecb06b (diff) | |
parent | 97b11eedff9d2e17101ad453caf9e48b73246719 (diff) |
Merge pull request #814 from dvdhrm/mfree
tree-wide: introduce mfree()
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-util.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c index 7a1a4b6df2..7619950320 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -714,45 +714,38 @@ static void test_cunescape(void) { assert_se(cunescape("abc\\\\\\\"\\b\\f\\a\\n\\r\\t\\v\\003\\177\\234\\313\\000\\x00", 0, &unescaped) < 0); assert_se(cunescape("abc\\\\\\\"\\b\\f\\a\\n\\r\\t\\v\\003\\177\\234\\313\\000\\x00", UNESCAPE_RELAX, &unescaped) >= 0); assert_se(streq_ptr(unescaped, "abc\\\"\b\f\a\n\r\t\v\003\177\234\313\\000\\x00")); - free(unescaped); - unescaped = NULL; + unescaped = mfree(unescaped); /* incomplete sequences */ assert_se(cunescape("\\x0", 0, &unescaped) < 0); assert_se(cunescape("\\x0", UNESCAPE_RELAX, &unescaped) >= 0); assert_se(streq_ptr(unescaped, "\\x0")); - free(unescaped); - unescaped = NULL; + unescaped = mfree(unescaped); assert_se(cunescape("\\x", 0, &unescaped) < 0); assert_se(cunescape("\\x", UNESCAPE_RELAX, &unescaped) >= 0); assert_se(streq_ptr(unescaped, "\\x")); - free(unescaped); - unescaped = NULL; + unescaped = mfree(unescaped); assert_se(cunescape("\\", 0, &unescaped) < 0); assert_se(cunescape("\\", UNESCAPE_RELAX, &unescaped) >= 0); assert_se(streq_ptr(unescaped, "\\")); - free(unescaped); - unescaped = NULL; + unescaped = mfree(unescaped); assert_se(cunescape("\\11", 0, &unescaped) < 0); assert_se(cunescape("\\11", UNESCAPE_RELAX, &unescaped) >= 0); assert_se(streq_ptr(unescaped, "\\11")); - free(unescaped); - unescaped = NULL; + unescaped = mfree(unescaped); assert_se(cunescape("\\1", 0, &unescaped) < 0); assert_se(cunescape("\\1", UNESCAPE_RELAX, &unescaped) >= 0); assert_se(streq_ptr(unescaped, "\\1")); - free(unescaped); - unescaped = NULL; + unescaped = mfree(unescaped); assert_se(cunescape("\\u0000", 0, &unescaped) < 0); assert_se(cunescape("\\u00DF\\U000000df\\u03a0\\U00000041", UNESCAPE_RELAX, &unescaped) >= 0); assert_se(streq_ptr(unescaped, "ßßΠA")); - free(unescaped); - unescaped = NULL; + unescaped = mfree(unescaped); assert_se(cunescape("\\073", 0, &unescaped) >= 0); assert_se(streq_ptr(unescaped, ";")); @@ -859,32 +852,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; |