From 0e66edb25437385c50d4054727995d9f6b6be50d Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 3 Sep 2014 09:51:14 -0400 Subject: Fix the leaks that valgrind found in the new routerset tests. (We have a tests-shouldn't-leak policy so that we won't accidentally ignore true-positives.) --- src/test/test_routerset.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/test') diff --git a/src/test/test_routerset.c b/src/test/test_routerset.c index 0ef2c538b9..0ea1ef2d89 100644 --- a/src/test/test_routerset.c +++ b/src/test/test_routerset.c @@ -1487,8 +1487,9 @@ NS(test_main)(void *arg) /* Just recreate list, so we can simply use routerset_free. */ set->list = smartlist_new(); - done: - routerset_free(set); + done: + routerset_free(set); + smartlist_free(out); } #undef NS_SUBMODULE @@ -1810,8 +1811,8 @@ NS(test_main)(void *arg) static void NS(test_main)(void *arg) { - const routerset_t *set; - char *s; + routerset_t *set = NULL; + char *s = NULL; (void)arg; set = NULL; @@ -1823,12 +1824,14 @@ NS(test_main)(void *arg) s = routerset_to_string(set); tt_str_op(s, ==, ""); tor_free(s); + routerset_free(set); set = NULL; set = routerset_new(); smartlist_add(set->list, tor_strndup("a", 1)); s = routerset_to_string(set); tt_str_op(s, ==, "a"); tor_free(s); + routerset_free(set); set = NULL; set = routerset_new(); smartlist_add(set->list, tor_strndup("a", 1)); @@ -1836,12 +1839,11 @@ NS(test_main)(void *arg) s = routerset_to_string(set); tt_str_op(s, ==, "a,b"); tor_free(s); + routerset_free(set); set = NULL; - done: - if (s) - tor_free(s); - if (set) - routerset_free((routerset_t *)set); + done: + tor_free(s); + routerset_free((routerset_t *)set); } #undef NS_SUBMODULE @@ -2036,24 +2038,22 @@ NS(test_main)(void *arg) void NS(smartlist_free)(smartlist_t *s) { - (void)s; CALLED(smartlist_free)++; + smartlist_free__real(s); } void NS(strmap_free)(strmap_t *map, void (*free_val)(void*)) { - (void)map; - (void)free_val; CALLED(strmap_free)++; + strmap_free__real(map, free_val); } void NS(digestmap_free)(digestmap_t *map, void (*free_val)(void*)) { - (void)map; - (void)free_val; CALLED(digestmap_free)++; + digestmap_free__real(map, free_val); } #undef NS_SUBMODULE -- cgit v1.2.3-54-g00ecf