diff options
author | dgp <dgp@users.sourceforge.net> | 2007-03-21 18:02:49 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2007-03-21 18:02:49 (GMT) |
commit | 1daf7b251b3f3c433644a0298c902c1c3032aa4d (patch) | |
tree | 15313c19062f14adf25226dab2cc03675bf43831 /generic/tclPreserve.c | |
parent | 02f9ee42d9908ad9e6c31c5c43aec3c3c65b3390 (diff) | |
download | tcl-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/tclPreserve.c')
-rw-r--r-- | generic/tclPreserve.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/generic/tclPreserve.c b/generic/tclPreserve.c index a721bb7..3c991ea 100644 --- a/generic/tclPreserve.c +++ b/generic/tclPreserve.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclPreserve.c,v 1.9 2006/08/10 12:15:31 dkf Exp $ + * RCS: @(#) $Id: tclPreserve.c,v 1.10 2007/03/21 18:02:51 dgp Exp $ */ #include "tclInt.h" @@ -38,7 +38,7 @@ typedef struct { * These variables are protected by "preserveMutex". */ -static Reference *refArray; /* First in array of references. */ +static Reference *refArray = NULL; /* First in array of references. */ static int spaceAvl = 0; /* Total number of structures available at * *firstRefPtr. */ static int inUse = 0; /* Count of structures currently in use in @@ -145,21 +145,9 @@ Tcl_Preserve( */ if (inUse == spaceAvl) { - if (spaceAvl == 0) { - refArray = (Reference *) ckalloc((unsigned) - (INITIAL_SIZE*sizeof(Reference))); - spaceAvl = INITIAL_SIZE; - } else { - Reference *new; - - new = (Reference *) ckalloc((unsigned) - (2*spaceAvl*sizeof(Reference))); - memcpy((void *) new, (void *) refArray, - spaceAvl*sizeof(Reference)); - ckfree((char *) refArray); - refArray = new; - spaceAvl *= 2; - } + spaceAvl = spaceAvl ? 2*spaceAvl : INITIAL_SIZE; + refArray = (Reference *) ckrealloc((char *) refArray, + spaceAvl * sizeof(Reference)); } /* |