summaryrefslogtreecommitdiffstats
path: root/generic/tclNamesp.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-06-22 17:09:15 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-06-22 17:09:15 (GMT)
commit6d2ef9cec6186ac320b6baea1c8c35d20b953061 (patch)
tree9c19ed0c63b59641ab72595ab8bc69512cc25b1c /generic/tclNamesp.c
parentabe71b0d5a315b3f7fa348e2318547e5180ef089 (diff)
downloadtcl-6d2ef9cec6186ac320b6baea1c8c35d20b953061.zip
tcl-6d2ef9cec6186ac320b6baea1c8c35d20b953061.tar.gz
tcl-6d2ef9cec6186ac320b6baea1c8c35d20b953061.tar.bz2
* generic/tclExecute.c: Revised TclStackRealloc() signature to better
* generic/tclInt.h: parallel (and fall back on) Tcl_Realloc. * generic/tclNamesp.c (TclResetShadowesCmdRefs): Replaced ckrealloc based allocations with TclStackRealloc allocations.
Diffstat (limited to 'generic/tclNamesp.c')
-rw-r--r--generic/tclNamesp.c35
1 files changed, 6 insertions, 29 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index 779ed22..70beba7 100644
--- a/generic/tclNamesp.c
+++ b/generic/tclNamesp.c
@@ -22,7 +22,7 @@
* 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.141 2007/06/20 19:27:40 dgp Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.142 2007/06/22 17:09:18 dgp Exp $
*/
#include "tclInt.h"
@@ -2660,17 +2660,10 @@ TclResetShadowedCmdRefs(
Namespace *trailNsPtr, *shadowNsPtr;
Namespace *globalNsPtr = (Namespace *) TclGetGlobalNamespace(interp);
int found, i;
-
- /*
- * This function generates an array used to hold the trail list. This
- * starts out with stack-allocated space but uses dynamically-allocated
- * storage if needed.
- */
-
- Namespace *(trailStorage[NUM_TRAIL_ELEMS]);
- Namespace **trailPtr = trailStorage;
int trailFront = -1;
int trailSize = NUM_TRAIL_ELEMS;
+ Namespace **trailPtr = (Namespace **)
+ TclStackAlloc(interp, trailSize * sizeof(Namespace *));
/*
* Start at the namespace containing the new command, and work up through
@@ -2748,30 +2741,14 @@ TclResetShadowedCmdRefs(
trailFront++;
if (trailFront == trailSize) {
- size_t currBytes = trailSize * sizeof(Namespace *);
int newSize = 2 * trailSize;
- size_t newBytes = newSize * sizeof(Namespace *);
-
- if (trailPtr != trailStorage) {
- trailPtr = (Namespace **) ckrealloc((char *) trailPtr,
- newBytes);
- } else {
- Namespace **newPtr = (Namespace **) ckalloc(newBytes);
- memcpy(newPtr, trailPtr, currBytes);
- trailPtr = newPtr;
- }
+ trailPtr = (Namespace **) TclStackRealloc(interp,
+ trailPtr, newSize * sizeof(Namespace *));
trailSize = newSize;
}
trailPtr[trailFront] = nsPtr;
}
-
- /*
- * Free any allocated storage.
- */
-
- if (trailPtr != trailStorage) {
- ckfree((char *) trailPtr);
- }
+ TclStackFree(interp, trailPtr);
}
/*