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/regexec.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/regexec.c')
-rw-r--r-- | generic/regexec.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/generic/regexec.c b/generic/regexec.c index 6862ef9..d39685c 100644 --- a/generic/regexec.c +++ b/generic/regexec.c @@ -170,8 +170,7 @@ exec( regmatch_t pmatch[], int flags) { - struct vars var; - register struct vars *v = &var; + AllocVars(v); int st; size_t n; int backref; @@ -185,9 +184,11 @@ exec( */ if (re == NULL || string == NULL || re->re_magic != REMAGIC) { + FreeVars(v); return REG_INVARG; } if (re->re_csize != sizeof(chr)) { + FreeVars(v); return REG_MIXED; } @@ -198,9 +199,11 @@ exec( v->re = re; v->g = (struct guts *)re->re_guts; if ((v->g->cflags®_EXPECT) && details == NULL) { + FreeVars(v); return REG_INVARG; } if (v->g->info®_UIMPOSSIBLE) { + FreeVars(v); return REG_NOMATCH; } backref = (v->g->info®_UBACKREF) ? 1 : 0; @@ -221,6 +224,7 @@ exec( MALLOC((v->g->nsub + 1) * sizeof(regmatch_t)); } if (v->pmatch == NULL) { + FreeVars(v); return REG_ESPACE; } v->nmatch = v->g->nsub + 1; @@ -247,6 +251,7 @@ exec( if (v->pmatch != pmatch && v->pmatch != mat) { FREE(v->pmatch); } + FreeVars(v); return REG_ESPACE; } } else { @@ -284,6 +289,7 @@ exec( if (v->mem != NULL && v->mem != mem) { FREE(v->mem); } + FreeVars(v); return st; } |