diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2012-01-18 17:23:20 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2012-01-18 17:23:20 +0000 |
commit | 758fe889107e073a9d7fd63d3f47c18519a0d0ae (patch) | |
tree | cac22c6af13c7641c19a821049cf8d75d661ad92 /pcre_exec.c | |
parent | 226fce73ff7f84d1d58444860a6330114c544ea3 (diff) | |
download | pcre-758fe889107e073a9d7fd63d3f47c18519a0d0ae.tar.gz |
Put top level heap frame on the stack.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@892 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'pcre_exec.c')
-rw-r--r-- | pcre_exec.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/pcre_exec.c b/pcre_exec.c index 56af9fc..02f7576 100644 --- a/pcre_exec.c +++ b/pcre_exec.c @@ -332,7 +332,7 @@ argument of match(), which never changes. */ {\ heapframe *oldframe = frame;\ frame = oldframe->Xprevframe;\ - (PUBL(stack_free))(oldframe);\ + if (oldframe != &frame_zero) (PUBL(stack_free))(oldframe);\ if (frame != NULL)\ {\ rrc = ra;\ @@ -485,13 +485,15 @@ BOOL caseless; int condcode; /* When recursion is not being used, all "local" variables that have to be -preserved over calls to RMATCH() are part of a "frame" which is obtained from -heap storage. Set up the top-level frame here; others are obtained from the -heap whenever RMATCH() does a "recursion". See the macro definitions above. */ +preserved over calls to RMATCH() are part of a "frame". We set up the top-level +frame on the stack here; subsequent instantiations are obtained from the heap +whenever RMATCH() does a "recursion". See the macro definitions above. Putting +the top-level on the stack rather than malloc-ing them all gives a performance +boost in many cases where there is not much "recursion". */ #ifdef NO_RECURSE -heapframe *frame = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe)); -if (frame == NULL) RRETURN(PCRE_ERROR_NOMEMORY); +heapframe frame_zero; +heapframe *frame = &frame_zero; frame->Xprevframe = NULL; /* Marks the top level */ /* Copy in the original argument variables */ |