diff options
author | dgp <dgp@users.sourceforge.net> | 2008-08-12 17:45:24 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2008-08-12 17:45:24 (GMT) |
commit | 06c2fab3218c8dc8a7a7582a182178f42c89964a (patch) | |
tree | a2d3b926f64f0c6299a04ba6c294b5ed145196cc /generic/tclProc.c | |
parent | 548d5bd4026829d315d293d2fce922b155fcdf4f (diff) | |
download | tcl-06c2fab3218c8dc8a7a7582a182178f42c89964a.zip tcl-06c2fab3218c8dc8a7a7582a182178f42c89964a.tar.gz tcl-06c2fab3218c8dc8a7a7582a182178f42c89964a.tar.bz2 |
* generic/tclProc.c (TclProcCompileProc): On recompile of
a proc, clear away any entries on the CompiledLocal list from the
previous compile. This will prevent compile of temporary variables
in the proc body from growing the localCache arbitrarily large.
Diffstat (limited to 'generic/tclProc.c')
-rw-r--r-- | generic/tclProc.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/generic/tclProc.c b/generic/tclProc.c index 9427f55..495e194 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclProc.c,v 1.158 2008/08/11 20:40:40 andreas_kupries Exp $ + * RCS: @(#) $Id: tclProc.c,v 1.159 2008/08/12 17:45:25 dgp Exp $ */ #include "tclInt.h" @@ -1998,6 +1998,30 @@ TclProcCompileProc( saveProcPtr = iPtr->compiledProcPtr; iPtr->compiledProcPtr = procPtr; + if (procPtr->numCompiledLocals > procPtr->numArgs) { + CompiledLocal *clPtr = procPtr->firstLocalPtr; + CompiledLocal *lastPtr = NULL; + int i, numArgs = procPtr->numArgs; + + for (i = 0; i < numArgs; i++) { + lastPtr = clPtr; + clPtr = clPtr->nextPtr; + } + + if (lastPtr) { + lastPtr->nextPtr = NULL; + } else { + procPtr->firstLocalPtr = NULL; + } + procPtr->lastLocalPtr = lastPtr; + while (clPtr) { + CompiledLocal *toFree = clPtr; + clPtr = clPtr->nextPtr; + ckfree((char *) toFree); + } + procPtr->numCompiledLocals = procPtr->numArgs; + } + (void) TclPushStackFrame(interp, &framePtr, (Tcl_Namespace *) nsPtr, /* isProcCallFrame */ 0); |