summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2007-03-20 21:20:10 (GMT)
committerdgp <dgp@users.sourceforge.net>2007-03-20 21:20:10 (GMT)
commite09c7776b3ee325bd972de72a641f9342f6c379a (patch)
tree6c22d75c83c3ca9a0d6dbf10f9f8e95a41f3870e /generic
parent1e14587ab8671097dbf480b432c3088434d59bef (diff)
downloadtcl-e09c7776b3ee325bd972de72a641f9342f6c379a.zip
tcl-e09c7776b3ee325bd972de72a641f9342f6c379a.tar.gz
tcl-e09c7776b3ee325bd972de72a641f9342f6c379a.tar.bz2
* generic/tclEnv.c: Some more ckalloc -> ckrealloc replacements.
* generic/tclLink.c:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclEnv.c20
-rw-r--r--generic/tclLink.c8
2 files changed, 9 insertions, 19 deletions
diff --git a/generic/tclEnv.c b/generic/tclEnv.c
index 12f4ab4..ab5a9a0 100644
--- a/generic/tclEnv.c
+++ b/generic/tclEnv.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclEnv.c,v 1.29 2006/10/31 22:24:39 das Exp $
+ * RCS: @(#) $Id: tclEnv.c,v 1.30 2007/03/20 21:20:12 dgp Exp $
*/
#include "tclInt.h"
@@ -638,7 +638,6 @@ ReplaceString(
char *newStr) /* New environment string. */
{
int i;
- char **newCache;
/*
* Check to see if the old value was allocated by Tcl. If so, it needs to
@@ -670,24 +669,17 @@ ReplaceString(
environCache[cacheSize-1] = NULL;
}
} else {
- int allocatedSize = (cacheSize + 5) * sizeof(char *);
-
/*
* We need to grow the cache in order to hold the new string.
*/
- newCache = (char **) ckalloc((unsigned) allocatedSize);
- (void) memset(newCache, (int) 0, (size_t) allocatedSize);
+ const int growth = 5;
- if (environCache) {
- memcpy((void *) newCache, (void *) environCache,
- (size_t) (cacheSize * sizeof(char*)));
- ckfree((char *) environCache);
- }
- environCache = newCache;
+ environCache = (char **) ckrealloc ((char *) environCache,
+ (cacheSize + growth) * sizeof(char *));
environCache[cacheSize] = newStr;
- environCache[cacheSize+1] = NULL;
- cacheSize += 5;
+ (void) memset(environCache+cacheSize+1, (int) 0, (size_t) (growth - 1));
+ cacheSize += growth;
}
}
diff --git a/generic/tclLink.c b/generic/tclLink.c
index fec4fdb..bdfa4db 100644
--- a/generic/tclLink.c
+++ b/generic/tclLink.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLink.c,v 1.19 2007/03/03 10:04:42 dkf Exp $
+ * RCS: @(#) $Id: tclLink.c,v 1.20 2007/03/20 21:20:12 dgp Exp $
*/
#include "tclInt.h"
@@ -518,10 +518,8 @@ LinkTraceProc(
value = Tcl_GetStringFromObj(valueObj, &valueLength);
valueLength++;
pp = (char **) linkPtr->addr;
- if (*pp != NULL) {
- ckfree(*pp);
- }
- *pp = (char *) ckalloc((unsigned) valueLength);
+
+ *pp = ckrealloc(*pp, valueLength);
memcpy(*pp, value, (unsigned) valueLength);
break;