From 59e699795921bab0541c577a5d90c1e9a6faf5f6 Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 23 May 2014 11:15:57 +0800 Subject: [PATCH] there is already a pointer guard in zmalloc --- src/edge.c | 4 +--- src/node.c | 16 +++++----------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/edge.c b/src/edge.c index b89dcb9..3f4d646 100644 --- a/src/edge.c +++ b/src/edge.c @@ -80,9 +80,7 @@ node * r3_edge_branch(edge *e, int dl) { } void r3_edge_free(edge * e) { - if (e->pattern) { - zfree(e->pattern); - } + zfree(e->pattern); if ( e->child ) { r3_tree_free(e->child); } diff --git a/src/node.c b/src/node.c index 671974b..c184837 100644 --- a/src/node.c +++ b/src/node.c @@ -70,12 +70,9 @@ void r3_tree_free(node * tree) { r3_edge_free(tree->edges[ i ]); } } - if (tree->edges) { - zfree(tree->edges); - } - if (tree->routes) { - zfree(tree->routes); - } + zfree(tree->edges); + zfree(tree->routes); + if (tree->pcre_pattern) { pcre_free(tree->pcre_pattern); } @@ -84,11 +81,8 @@ void r3_tree_free(node * tree) { pcre_free_study(tree->pcre_extra); } #endif - - if (tree->combined_pattern) - zfree(tree->combined_pattern); - if (tree->ov) - zfree(tree->ov); + zfree(tree->combined_pattern); + zfree(tree->ov); zfree(tree); tree = NULL; }