From 238aee085f217a6e5dfcad2dc57d1f4a7bd28177 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 21 May 2014 18:16:48 +0800 Subject: [PATCH] use pcre's own functions to free pcre related structures --- src/node.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/node.c b/src/node.c index aa459cd..33de25d 100644 --- a/src/node.c +++ b/src/node.c @@ -76,12 +76,12 @@ void r3_tree_free(node * tree) { if (tree->routes) { zfree(tree->routes); } - /* - if (tree->pcre_pattern) - zfree(tree->pcre_pattern); - if (tree->pcre_extra) - zfree(tree->pcre_extra); - */ + if (tree->pcre_pattern) { + pcre_free(tree->pcre_pattern); + } + if (n->pcre_extra) { + pcre_free_study(n->pcre_extra); + } if (tree->combined_pattern) zfree(tree->combined_pattern); if (tree->ov) @@ -205,14 +205,12 @@ void r3_tree_compile_patterns(node * n) { int erroffset; unsigned int option_bits = 0; - /* - if (n->pcre_pattern) - zfree(n->pcre_pattern); - if (n->pcre_extra) - zfree(n->pcre_extra); - */ - - // n->pcre_pattern; + if (tree->pcre_pattern) { + pcre_free(tree->pcre_pattern); + } + if (n->pcre_extra) { + pcre_free_study(n->pcre_extra); + } n->pcre_pattern = pcre_compile( n->combined_pattern, /* the pattern */ option_bits, /* default options */