diff options
author | dgp <dgp@noemail.net> | 2007-03-21 18:02:49 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2007-03-21 18:02:49 (GMT) |
commit | 6dfc16e6f56150ea6dc17989b92cb9cb6def1577 (patch) | |
tree | 15313c19062f14adf25226dab2cc03675bf43831 /generic/tclPreserve.c | |
parent | 82fcd65f2be55ca85bdbcdbf39428d93ea7e8f42 (diff) | |
download | tcl-6dfc16e6f56150ea6dc17989b92cb9cb6def1577.zip tcl-6dfc16e6f56150ea6dc17989b92cb9cb6def1577.tar.gz tcl-6dfc16e6f56150ea6dc17989b92cb9cb6def1577.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:
FossilOrigin-Name: aa6b9bf6a420cb7cee546906b1fca5706ee025fd
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)); } /* |