summaryrefslogtreecommitdiffstats
path: root/generic/regcomp.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/regcomp.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/regcomp.c')
-rw-r--r--generic/regcomp.c12
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&REG_QUOTE) && (flags&(REG_ADVANCED|REG_EXPANDED|REG_NEWLINE))) {
+ FreeVars(v);
return REG_INVARG;
}
if (!(flags&REG_EXTENDED) && (flags&REG_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;
}
/*