diff --git a/ChangeLog b/ChangeLog index a8bd225f09..71b96d81e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Nov 30 00:12:57 2004 Kazuo Saito + + * regparse.c: now handles many alternatives (over 500000) + in regexp. [ruby-dev:24773] + Mon Nov 29 16:06:04 2004 Nobuyoshi Nakada * ext/stringio/stringio.c (strio_write): insufficiently filled string diff --git a/regparse.c b/regparse.c index f4b72c3e84..2d26786771 100644 --- a/regparse.c +++ b/regparse.c @@ -866,6 +866,7 @@ static FreeNode* FreeNodeList = (FreeNode* )NULL; extern void onig_node_free(Node* node) { + start: if (IS_NULL(node)) return ; switch (NTYPE(node)) { @@ -878,7 +879,23 @@ onig_node_free(Node* node) case N_LIST: case N_ALT: onig_node_free(NCONS(node).left); - onig_node_free(NCONS(node).right); + /* onig_node_free(NCONS(node).right); */ + { + Node* next_node = NCONS(node).right; + +#ifdef USE_RECYCLE_NODE + { + FreeNode* n = (FreeNode* )node; + n->next = FreeNodeList; + FreeNodeList = n; + } +#else + xfree(node); +#endif + + node = next_node; + goto start; + } break; case N_CCLASS: @@ -909,9 +926,7 @@ onig_node_free(Node* node) #ifdef USE_RECYCLE_NODE { - FreeNode* n; - - n = (FreeNode* )node; + FreeNode* n = (FreeNode* )node; n->next = FreeNodeList; FreeNodeList = n; }