free edge struct

This commit is contained in:
c9s 2014-05-21 18:12:14 +08:00
parent 7d288404c7
commit 6762025fe6
4 changed files with 26 additions and 23 deletions

View file

@ -85,5 +85,7 @@ void r3_edge_free(edge * e) {
if ( e->child ) {
r3_tree_free(e->child);
}
// free itself
zfree(e);
}

View file

@ -65,16 +65,17 @@ node * r3_tree_create(int cap) {
}
void r3_tree_free(node * tree) {
if (tree) {
for (int i = 0 ; i < tree->edge_len ; i++ ) {
if (tree->edges[i]) {
r3_edge_free(tree->edges[ i ]);
}
}
if (tree->edges)
if (tree->edges) {
zfree(tree->edges);
if (tree->routes)
}
if (tree->routes) {
zfree(tree->routes);
}
/*
if (tree->pcre_pattern)
zfree(tree->pcre_pattern);
@ -88,7 +89,6 @@ void r3_tree_free(node * tree) {
zfree(tree);
tree = NULL;
}
}

View file

@ -443,3 +443,4 @@
1400659046,19754150.71
1400666823,6406965.25
1400666950,6684744.95
1400667091,6771202.47

1 1400242718 5649455.80
443 1400659046 19754150.71
444 1400666823 6406965.25
445 1400666950 6684744.95
446 1400667091 6771202.47

View file

@ -20,9 +20,9 @@ END_TEST
START_TEST (test_r3_node_construct_and_free)
{
node * n = r3_tree_create(10);
node * child = r3_tree_create(3);
node * another_tree = r3_tree_create(3);
r3_tree_free(n);
r3_tree_free(child);
r3_tree_free(another_tree);
}
END_TEST