diff options
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)); } /* |