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/regcomp.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/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; } /* |