diff options
author | dgp <dgp@noemail.net> | 2007-06-22 20:42:21 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2007-06-22 20:42:21 (GMT) |
commit | 8a2e9a2ffd22c225279b50b0f1f32ebac4d48466 (patch) | |
tree | f2b17196e1b5deb5121fdc81218a070a64828e5b /generic/tclScan.c | |
parent | 347869ef332192286b4039c6b59c95d91773ed39 (diff) | |
download | tcl-8a2e9a2ffd22c225279b50b0f1f32ebac4d48466.zip tcl-8a2e9a2ffd22c225279b50b0f1f32ebac4d48466.tar.gz tcl-8a2e9a2ffd22c225279b50b0f1f32ebac4d48466.tar.bz2 |
* generic/tclCmdIL.c: More conversions to use TclStackAlloc.
* generic/tclScan.c:
FossilOrigin-Name: ebf25c463a94c4cfa9e0a63d2204cd0d023284e6
Diffstat (limited to 'generic/tclScan.c')
-rw-r--r-- | generic/tclScan.c | 33 |
1 files changed, 8 insertions, 25 deletions
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 } /* |