From de7d9ee437bc0e5d72f8c6744e1df7ea7b64d2e9 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sat, 4 Jul 2015 17:53:11 +0200 Subject: [PATCH] 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(). --- src/edge.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/edge.c b/src/edge.c index 6539630..0e35cd1 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); } -- 2.25.1