From 06c2fab3218c8dc8a7a7582a182178f42c89964a Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 12 Aug 2008 17:45:24 +0000 Subject: * 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. --- ChangeLog | 5 +++++ generic/tclProc.c | 26 +++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 105e01f..7ece66a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-08-08 Don Porter 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); -- cgit v0.12