summaryrefslogtreecommitdiffstats
path: root/generic/tclScan.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-06-25 18:53:28 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-06-25 18:53:28 (GMT)
commiteadf07dc2cd9a4faad580c36e2d7112f002bd033 (patch)
tree57b5b348b85d504d4bf7f5ac1b4e12015a94f251 /generic/tclScan.c
parentfa238fdc3fd76a6ec566a17c9d69cdda3b12d2e8 (diff)
downloadtcl-eadf07dc2cd9a4faad580c36e2d7112f002bd033.zip
tcl-eadf07dc2cd9a4faad580c36e2d7112f002bd033.tar.gz
tcl-eadf07dc2cd9a4faad580c36e2d7112f002bd033.tar.bz2
merge updates from HEAD
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..1a05b8c 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.24.6.1 2007/06/25 18:53:31 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
}
/*