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,29 +65,29 @@ 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 ]);
}
for (int i = 0 ; i < tree->edge_len ; i++ ) {
if (tree->edges[i]) {
r3_edge_free(tree->edges[ i ]);
}
if (tree->edges)
zfree(tree->edges);
if (tree->routes)
zfree(tree->routes);
/*
if (tree->pcre_pattern)
zfree(tree->pcre_pattern);
if (tree->pcre_extra)
zfree(tree->pcre_extra);
*/
if (tree->combined_pattern)
zfree(tree->combined_pattern);
if (tree->ov)
zfree(tree->ov);
zfree(tree);
tree = NULL;
}
if (tree->edges) {
zfree(tree->edges);
}
if (tree->routes) {
zfree(tree->routes);
}
/*
if (tree->pcre_pattern)
zfree(tree->pcre_pattern);
if (tree->pcre_extra)
zfree(tree->pcre_extra);
*/
if (tree->combined_pattern)
zfree(tree->combined_pattern);
if (tree->ov)
zfree(tree->ov);
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