summaryrefslogtreecommitdiffstats
path: root/generic/tclNamesp.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-03-21 18:02:49 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-03-21 18:02:49 (GMT)
commit1daf7b251b3f3c433644a0298c902c1c3032aa4d (patch)
tree15313c19062f14adf25226dab2cc03675bf43831 /generic/tclNamesp.c
parent02f9ee42d9908ad9e6c31c5c43aec3c3c65b3390 (diff)
downloadtcl-1daf7b251b3f3c433644a0298c902c1c3032aa4d.zip
tcl-1daf7b251b3f3c433644a0298c902c1c3032aa4d.tar.gz
tcl-1daf7b251b3f3c433644a0298c902c1c3032aa4d.tar.bz2
* generic/tclExecute.c: More ckalloc -> ckrealloc conversions.
* generic/tclLiteral.c: * generic/tclNamesp.c: * generic/tclParse.c: * generic/tclPreserve.c: * generic/tclStringObj.c: * generic/tclUtil.c:
Diffstat (limited to 'generic/tclNamesp.c')
-rw-r--r--generic/tclNamesp.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/generic/tclNamesp.c b/generic/tclNamesp.c
index 34a449d..605a7d8 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.126 2007/03/12 19:10:49 dgp Exp $
+ * RCS: @(#) $Id: tclNamesp.c,v 1.127 2007/03/21 18:02:51 dgp Exp $
*/
#include "tclInt.h"
@@ -1307,21 +1307,12 @@ Tcl_Export(
*/
neededElems = nsPtr->numExportPatterns + 1;
- if (nsPtr->exportArrayPtr == NULL) {
- nsPtr->exportArrayPtr = (char **)
- ckalloc((unsigned) (INIT_EXPORT_PATTERNS * sizeof(char *)));
- nsPtr->numExportPatterns = 0;
- nsPtr->maxExportPatterns = INIT_EXPORT_PATTERNS;
- } else if (neededElems > nsPtr->maxExportPatterns) {
- int numNewElems = 2 * nsPtr->maxExportPatterns;
- size_t currBytes = nsPtr->numExportPatterns * sizeof(char *);
- size_t newBytes = numNewElems * sizeof(char *);
- char **newPtr = (char **) ckalloc((unsigned) newBytes);
-
- memcpy(newPtr, nsPtr->exportArrayPtr, currBytes);
- ckfree((char *) nsPtr->exportArrayPtr);
- nsPtr->exportArrayPtr = (char **) newPtr;
- nsPtr->maxExportPatterns = numNewElems;
+ if (neededElems > nsPtr->maxExportPatterns) {
+ nsPtr->maxExportPatterns = nsPtr->maxExportPatterns ?
+ 2 * nsPtr->maxExportPatterns : INIT_EXPORT_PATTERNS;
+ nsPtr->exportArrayPtr = (char **) ckrealloc(
+ (char *)nsPtr->exportArrayPtr,
+ sizeof(char *) * nsPtr->maxExportPatterns);
}
/*
@@ -2763,13 +2754,15 @@ TclResetShadowedCmdRefs(
size_t currBytes = trailSize * sizeof(Namespace *);
int newSize = 2 * trailSize;
size_t newBytes = newSize * sizeof(Namespace *);
- Namespace **newPtr = (Namespace **) ckalloc((unsigned) newBytes);
- memcpy(newPtr, trailPtr, currBytes);
if (trailPtr != trailStorage) {
- ckfree((char *) trailPtr);
+ trailPtr = (Namespace **) ckrealloc((char *) trailPtr,
+ newBytes);
+ } else {
+ Namespace **newPtr = (Namespace **) ckalloc(newBytes);
+ memcpy(newPtr, trailPtr, currBytes);
+ trailPtr = newPtr;
}
- trailPtr = newPtr;
trailSize = newSize;
}
trailPtr[trailFront] = nsPtr;