diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2007-01-10 15:30:59 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2007-01-10 15:30:59 (GMT) |
commit | f299701a39e378d072a5c5d97396675ce735b414 (patch) | |
tree | a89fe1c2a582e5bc126b2ec3cf259c3c61a28a55 /generic/regexec.c | |
parent | 0461303eb629c1a59984468e671be1d59c424aae (diff) | |
download | tcl-f299701a39e378d072a5c5d97396675ce735b414.zip tcl-f299701a39e378d072a5c5d97396675ce735b414.tar.gz tcl-f299701a39e378d072a5c5d97396675ce735b414.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.
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; } |