diff options
author | dgp <dgp@users.sourceforge.net> | 2007-03-20 21:20:10 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2007-03-20 21:20:10 (GMT) |
commit | e09c7776b3ee325bd972de72a641f9342f6c379a (patch) | |
tree | 6c22d75c83c3ca9a0d6dbf10f9f8e95a41f3870e | |
parent | 1e14587ab8671097dbf480b432c3088434d59bef (diff) | |
download | tcl-e09c7776b3ee325bd972de72a641f9342f6c379a.zip tcl-e09c7776b3ee325bd972de72a641f9342f6c379a.tar.gz tcl-e09c7776b3ee325bd972de72a641f9342f6c379a.tar.bz2 |
* generic/tclEnv.c: Some more ckalloc -> ckrealloc replacements.
* generic/tclLink.c:
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tclEnv.c | 20 | ||||
-rw-r--r-- | generic/tclLink.c | 8 |
3 files changed, 14 insertions, 19 deletions
@@ -1,3 +1,8 @@ +2007-03-20 Don Porter <dgp@users.sourceforge.net> + + * generic/tclEnv.c: Some more ckalloc -> ckrealloc replacements. + * generic/tclLink.c: + 2007-03-20 Kevin B. Kenny <kennykb@acm.org> * generic/tclDate.c: Rebuilt, despite Donal Fellows's comment when 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; |