From 3807db001d71c51e53c1897ae067671f5b771f2f Mon Sep 17 00:00:00 2001 From: Sebastian Hahn Date: Mon, 28 Sep 2009 16:37:01 +0200 Subject: *_free functions now accept NULL Some *_free functions threw asserts when passed NULL. Now all of them accept NULL as input and perform no action when called that way. This gains us consistence for our free functions, and allows some code simplifications where an explicit null check is no longer necessary. --- src/or/policies.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/or/policies.c') diff --git a/src/or/policies.c b/src/or/policies.c index 023cd472f..a852ce192 100644 --- a/src/or/policies.c +++ b/src/or/policies.c @@ -1276,7 +1276,8 @@ getinfo_helper_policies(control_connection_t *conn, void addr_policy_list_free(smartlist_t *lst) { - if (!lst) return; + if (!lst) + return; SMARTLIST_FOREACH(lst, addr_policy_t *, policy, addr_policy_free(policy)); smartlist_free(lst); } @@ -1285,19 +1286,20 @@ addr_policy_list_free(smartlist_t *lst) void addr_policy_free(addr_policy_t *p) { - if (p) { - if (--p->refcnt <= 0) { - if (p->is_canonical) { - policy_map_ent_t search, *found; - search.policy = p; - found = HT_REMOVE(policy_map, &policy_root, &search); - if (found) { - tor_assert(p == found->policy); - tor_free(found); - } + if (!p) + return; + + if (--p->refcnt <= 0) { + if (p->is_canonical) { + policy_map_ent_t search, *found; + search.policy = p; + found = HT_REMOVE(policy_map, &policy_root, &search); + if (found) { + tor_assert(p == found->policy); + tor_free(found); } - tor_free(p); } + tor_free(p); } } -- cgit v1.2.3