diff options
author | dkf <dkf@noemail.net> | 2007-01-10 15:30:59 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2007-01-10 15:30:59 (GMT) |
commit | cdc382cd3873562b6875fc756aa9c83c668d7a67 (patch) | |
tree | a89fe1c2a582e5bc126b2ec3cf259c3c61a28a55 /generic/regcomp.c | |
parent | 1b5ff301e37fa0df7e2e1bed7e1dab6391f1924e (diff) | |
download | tcl-cdc382cd3873562b6875fc756aa9c83c668d7a67.zip tcl-cdc382cd3873562b6875fc756aa9c83c668d7a67.tar.gz tcl-cdc382cd3873562b6875fc756aa9c83c668d7a67.tar.bz2 |
Arrange for RE engine workspace to be held in TSD. This is safe, less
C-stack-hungry than before, and faster than just using heap allocation.
FossilOrigin-Name: d29fdf3177fb86dc3a4072a91731bff106a5357b
Diffstat (limited to 'generic/regcomp.c')
-rw-r--r-- | generic/regcomp.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/generic/regcomp.c b/generic/regcomp.c index 0d6f066..049ad69 100644 --- a/generic/regcomp.c +++ b/generic/regcomp.c @@ -287,8 +287,7 @@ compile( size_t len, int flags) { - struct vars var; - struct vars *v = &var; + AllocVars(v); struct guts *g; int i; size_t j; @@ -300,12 +299,15 @@ compile( */ if (re == NULL || string == NULL) { + FreeVars(v); return REG_INVARG; } if ((flags®_QUOTE) && (flags&(REG_ADVANCED|REG_EXPANDED|REG_NEWLINE))) { + FreeVars(v); return REG_INVARG; } if (!(flags®_EXTENDED) && (flags®_ADVF)) { + FreeVars(v); return REG_INVARG; } @@ -525,6 +527,8 @@ freev( struct vars *v, int err) { + register int ret; + if (v->re != NULL) { rfree(v->re); } @@ -554,7 +558,9 @@ freev( } ERR(err); /* nop if err==0 */ - return v->err; + ret = v->err; + FreeVars(v); + return ret; } /* |