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().
This commit is contained in:
parent
36cec9af88
commit
de7d9ee437
1 changed files with 1 additions and 6 deletions
|
@ -64,12 +64,6 @@ void free_edge_tree(splay_tree_t *edge_tree) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void exit_edges(void) {
|
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);
|
splay_delete_tree(edge_weight_tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +75,7 @@ edge_t *new_edge(void) {
|
||||||
|
|
||||||
void free_edge(edge_t *e) {
|
void free_edge(edge_t *e) {
|
||||||
sockaddrfree(&e->address);
|
sockaddrfree(&e->address);
|
||||||
|
sockaddrfree(&e->local_address);
|
||||||
|
|
||||||
free(e);
|
free(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue