From: Guus Sliepen Date: Sat, 4 Jul 2015 15:53:11 +0000 (+0200) Subject: Call sockaddrfree(&e->local_address) in free_edge() instead of exit_edges(). X-Git-Tag: release-1.1pre12~110 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=de7d9ee437bc0e5d72f8c6744e1df7ea7b64d2e9;p=tinc Call sockaddrfree(&e->local_address) in free_edge() instead of exit_edges(). The proper place to clean up resources of objects is in their destructor. This makes sure proper cleanup when edge_del() is called as well. At exit, free_edge() is called on all edges by free_edge_tree(), which is called by exit_nodes(). --- diff --git a/src/edge.c b/src/edge.c index 65396309..0e35cd1e 100644 --- a/src/edge.c +++ b/src/edge.c @@ -64,12 +64,6 @@ void free_edge_tree(splay_tree_t *edge_tree) { } void exit_edges(void) { - // since edge_weight_tree does not have delete action defined - // we have to cleanup it on exit - for splay_each(edge_t, e, edge_weight_tree) { - sockaddrfree(&e->address); - sockaddrfree(&e->local_address); - } splay_delete_tree(edge_weight_tree); } @@ -81,6 +75,7 @@ edge_t *new_edge(void) { void free_edge(edge_t *e) { sockaddrfree(&e->address); + sockaddrfree(&e->local_address); free(e); }