diff options
author | dgp <dgp@users.sourceforge.net> | 2007-06-22 20:42:22 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2007-06-22 20:42:22 (GMT) |
commit | 502f655491642c7cc617929b6e51b9e966d317bd (patch) | |
tree | f2b17196e1b5deb5121fdc81218a070a64828e5b | |
parent | 6d2ef9cec6186ac320b6baea1c8c35d20b953061 (diff) | |
download | tcl-502f655491642c7cc617929b6e51b9e966d317bd.zip tcl-502f655491642c7cc617929b6e51b9e966d317bd.tar.gz tcl-502f655491642c7cc617929b6e51b9e966d317bd.tar.bz2 |
* generic/tclCmdIL.c: More conversions to use TclStackAlloc.
* generic/tclScan.c:
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | generic/tclCmdIL.c | 8 | ||||
-rw-r--r-- | generic/tclNamesp.c | 11 | ||||
-rw-r--r-- | generic/tclScan.c | 33 |
4 files changed, 18 insertions, 37 deletions
@@ -6,6 +6,9 @@ * generic/tclNamesp.c (TclResetShadowesCmdRefs): Replaced ckrealloc based allocations with TclStackRealloc allocations. + * generic/tclCmdIL.c: More conversions to use TclStackAlloc. + * generic/tclScan.c: + 2007-06-21 Don Porter <dgp@users.sourceforge.net> * generic/tclBasic.c: Move most instances of the Tcl_Parse struct diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 2112d6f..702bdca 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -16,7 +16,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdIL.c,v 1.118 2007/06/20 18:46:07 dgp Exp $ + * RCS: @(#) $Id: tclCmdIL.c,v 1.119 2007/06/22 20:42:23 dgp Exp $ */ #include "tclInt.h" @@ -4026,7 +4026,9 @@ Tcl_LsortObjCmd( if (sortInfo.resultCode != TCL_OK || length <= 0) { goto done; } - elementArray = (SortElement *) ckalloc(length * sizeof(SortElement)); + + elementArray = (SortElement *) + TclStackAlloc(interp, length * sizeof(SortElement)); for (i=0; i < length; i++){ elementArray[i].objPtr = listObjPtrs[i]; elementArray[i].count = 0; @@ -4064,7 +4066,7 @@ Tcl_LsortObjCmd( } Tcl_SetObjResult(interp, resultPtr); } - ckfree((char *) elementArray); + TclStackFree(interp, elementArray); done: if (sortInfo.sortMode == SORTMODE_COMMAND) { diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c index 70beba7..098b8ba 100644 --- a/generic/tclNamesp.c +++ b/generic/tclNamesp.c @@ -22,19 +22,12 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclNamesp.c,v 1.142 2007/06/22 17:09:18 dgp Exp $ + * RCS: @(#) $Id: tclNamesp.c,v 1.143 2007/06/22 20:42:24 dgp Exp $ */ #include "tclInt.h" /* - * Initial size of stack allocated space for tail list - used when resetting - * shadowed command references in the function TclResetShadowedCmdRefs. - */ - -#define NUM_TRAIL_ELEMS 5 - -/* * Thread-local storage used to avoid having a global lock on data that is not * limited to a single interpreter. */ @@ -2661,7 +2654,7 @@ TclResetShadowedCmdRefs( Namespace *globalNsPtr = (Namespace *) TclGetGlobalNamespace(interp); int found, i; int trailFront = -1; - int trailSize = NUM_TRAIL_ELEMS; + int trailSize = 5; /* formerly NUM_TRAIL_ELEMS */ Namespace **trailPtr = (Namespace **) TclStackAlloc(interp, trailSize * sizeof(Namespace *)); diff --git a/generic/tclScan.c b/generic/tclScan.c index 8696240..aa1fe75 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclScan.c,v 1.24 2006/04/25 17:15:25 dgp Exp $ + * RCS: @(#) $Id: tclScan.c,v 1.25 2007/06/22 20:42:24 dgp Exp $ */ #include "tclInt.h" @@ -258,13 +258,11 @@ ValidateFormat( int *totalSubs) /* The number of variables that will be * required. */ { -#define STATIC_LIST_SIZE 16 int gotXpg, gotSequential, value, i, flags; char *end; Tcl_UniChar ch; - int staticAssign[STATIC_LIST_SIZE]; - int *nassign = staticAssign; - int objIndex, xpgSize, nspace = STATIC_LIST_SIZE; + int objIndex, xpgSize, nspace = numVars; + int *nassign = (int *) TclStackAlloc(interp, nspace * sizeof(int)); char buf[TCL_UTF_MAX+1]; /* @@ -273,10 +271,6 @@ ValidateFormat( * is multiply assigned or left unassigned. */ - if (numVars > nspace) { - nassign = (int*)ckalloc(sizeof(int) * numVars); - nspace = numVars; - } for (i = 0; i < nspace; i++) { nassign[i] = 0; } @@ -475,16 +469,10 @@ ValidateFormat( if (xpgSize) { nspace = xpgSize; } else { - nspace += STATIC_LIST_SIZE; - } - if (nassign == staticAssign) { - nassign = (void *) ckalloc(nspace * sizeof(int)); - memcpy((void *) nassign, (void *) staticAssign, - sizeof(staticAssign)); - } else { - nassign = (void *) ckrealloc((void *)nassign, - nspace * sizeof(int)); + nspace += 16; /* formerly STATIC_LIST_SIZE */ } + nassign = (int *) TclStackRealloc(interp, nassign, + nspace * sizeof(int)); for (i = value; i < nspace; i++) { nassign[i] = 0; } @@ -527,9 +515,7 @@ ValidateFormat( } } - if (nassign != staticAssign) { - ckfree((char *)nassign); - } + TclStackFree(interp, nassign); return TCL_OK; badIndex: @@ -543,11 +529,8 @@ ValidateFormat( } error: - if (nassign != staticAssign) { - ckfree((char *)nassign); - } + TclStackFree(interp, nassign); return TCL_ERROR; -#undef STATIC_LIST_SIZE } /* |