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 /generic/tclEnv.c | |
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:
Diffstat (limited to 'generic/tclEnv.c')
-rw-r--r-- | generic/tclEnv.c | 20 |
1 files changed, 6 insertions, 14 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; } } |