summaryrefslogtreecommitdiffstats
path: root/generic/regexec.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2007-01-10 15:30:59 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2007-01-10 15:30:59 (GMT)
commitf299701a39e378d072a5c5d97396675ce735b414 (patch)
treea89fe1c2a582e5bc126b2ec3cf259c3c61a28a55 /generic/regexec.c
parent0461303eb629c1a59984468e671be1d59c424aae (diff)
downloadtcl-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.c10
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&REG_EXPECT) && details == NULL) {
+ FreeVars(v);
return REG_INVARG;
}
if (v->g->info&REG_UIMPOSSIBLE) {
+ FreeVars(v);
return REG_NOMATCH;
}
backref = (v->g->info&REG_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;
}