summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2008-08-21 09:43:51 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2008-08-21 09:43:51 (GMT)
commit67523410e4e667700dc7c151d1573e2ac4abc1d7 (patch)
tree6b6f8ade7994a04c4c66e552c110147f0488c3ca /generic
parent3c8fa66b5466d2d5a538237f040d6dcdfb4b0346 (diff)
downloadtk-67523410e4e667700dc7c151d1573e2ac4abc1d7.zip
tk-67523410e4e667700dc7c151d1573e2ac4abc1d7.tar.gz
tk-67523410e4e667700dc7c151d1573e2ac4abc1d7.tar.bz2
Use ckrealloc to resize arrays...
Diffstat (limited to 'generic')
-rw-r--r--generic/tkOption.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/generic/tkOption.c b/generic/tkOption.c
index 06b67f9..b5a147e 100644
--- a/generic/tkOption.c
+++ b/generic/tkOption.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: tkOption.c,v 1.25 2008/04/27 22:38:56 dkf Exp $
+ * RCS: @(#) $Id: tkOption.c,v 1.26 2008/08/21 09:43:53 dkf Exp $
*/
#include "tkInt.h"
@@ -1188,16 +1188,12 @@ ExtendArray(
*/
if (arrayPtr->numUsed >= arrayPtr->arraySize) {
- register ElArray *newPtr;
-
- newPtr = (ElArray *) ckalloc(EL_ARRAY_SIZE(2*arrayPtr->arraySize));
- newPtr->arraySize = 2*arrayPtr->arraySize;
- newPtr->numUsed = arrayPtr->numUsed;
- newPtr->nextToUse = &newPtr->els[newPtr->numUsed];
- memcpy(newPtr->els, arrayPtr->els,
- arrayPtr->arraySize * sizeof(Element));
- ckfree((char *) arrayPtr);
- arrayPtr = newPtr;
+ register int newSize = 2*arrayPtr->arraySize;
+
+ arrayPtr = (ElArray *)
+ ckrealloc((char *) arrayPtr, EL_ARRAY_SIZE(newSize));
+ arrayPtr->arraySize = newSize;
+ arrayPtr->nextToUse = &arrayPtr->els[arrayPtr->numUsed];
}
*arrayPtr->nextToUse = *elPtr;