summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclProc.c26
2 files changed, 30 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 105e01f..7ece66a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2008-08-08 Don Porter <dgp@users.sourceforge.net>S
+ * 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.
+
* README: Bump version number to 8.6a2
* generic/tcl.h:
* library/init.tcl:
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);