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().
}
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);
}
void free_edge(edge_t *e) {
sockaddrfree(&e->address);
+ sockaddrfree(&e->local_address);
free(e);
}