summaryrefslogtreecommitdiffstats
path: root/generic/tclNamesp.c
diff options
context:
space:
mode:
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);
}
/*