summaryrefslogtreecommitdiffstats
path: root/generic/tclScan.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-06-22 20:42:22 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-06-22 20:42:22 (GMT)
commit502f655491642c7cc617929b6e51b9e966d317bd (patch)
treef2b17196e1b5deb5121fdc81218a070a64828e5b /generic/tclScan.c
parent6d2ef9cec6186ac320b6baea1c8c35d20b953061 (diff)
downloadtcl-502f655491642c7cc617929b6e51b9e966d317bd.zip
tcl-502f655491642c7cc617929b6e51b9e966d317bd.tar.gz
tcl-502f655491642c7cc617929b6e51b9e966d317bd.tar.bz2
* generic/tclCmdIL.c: More conversions to use TclStackAlloc.
* generic/tclScan.c:
Diffstat (limited to 'generic/tclScan.c')
-rw-r--r--generic/tclScan.c33
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
}
/*