Cleaning improved when quitting.
parent
22c097789f
commit
be71494725
|
@ -38,9 +38,12 @@ void visit_node_pre_order(node *q, void (*callback)(node *)) {
|
||||||
void node_destroy(list *q) {
|
void node_destroy(list *q) {
|
||||||
void (*func)(node *) = (void (*)(node *))free;
|
void (*func)(node *) = (void (*)(node *))free;
|
||||||
list *t = q;
|
list *t = q;
|
||||||
|
list *prev = NULL;
|
||||||
while (t) {
|
while (t) {
|
||||||
visit_node_post_order(t->node, func);
|
visit_node_post_order(t->node, func);
|
||||||
|
prev = t;
|
||||||
t = t->next;
|
t = t->next;
|
||||||
|
free(prev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue