diff options
author | dgp <dgp@users.sourceforge.net> | 2007-03-19 21:00:53 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2007-03-19 21:00:53 (GMT) |
commit | 0e0dd5df591d2e9105f59794f7bb6f15f4ed091f (patch) | |
tree | 6253c954970941d7e6f8d598071d091d165c64b6 /generic/tclBinary.c | |
parent | e5a9a4d6a85c0dcc262e00d46418410e63d63fa0 (diff) | |
download | tcl-0e0dd5df591d2e9105f59794f7bb6f15f4ed091f.zip tcl-0e0dd5df591d2e9105f59794f7bb6f15f4ed091f.tar.gz tcl-0e0dd5df591d2e9105f59794f7bb6f15f4ed091f.tar.bz2 |
* generic/tclBinary.c (Tcl_SetByteArrayLength): Replaced ckalloc() /
memcpy() sequence with ckrealloc() call.
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r-- | generic/tclBinary.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 8ac5cb9..485383a 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclBinary.c,v 1.33 2007/02/20 23:24:04 nijtmans Exp $ + * RCS: @(#) $Id: tclBinary.c,v 1.34 2007/03/19 21:00:53 dgp Exp $ */ #include "tclInt.h" @@ -346,7 +346,7 @@ Tcl_SetByteArrayLength( Tcl_Obj *objPtr, /* The ByteArray object. */ int length) /* New length for internal byte array. */ { - ByteArray *byteArrayPtr, *newByteArrayPtr; + ByteArray *byteArrayPtr; if (Tcl_IsShared(objPtr)) { Tcl_Panic("%s called with shared object", "Tcl_SetByteArrayLength"); @@ -357,13 +357,9 @@ Tcl_SetByteArrayLength( byteArrayPtr = GET_BYTEARRAY(objPtr); if (length > byteArrayPtr->allocated) { - newByteArrayPtr = (ByteArray *) ckalloc(BYTEARRAY_SIZE(length)); - newByteArrayPtr->used = length; - newByteArrayPtr->allocated = length; - memcpy(newByteArrayPtr->bytes, byteArrayPtr->bytes, - (size_t) byteArrayPtr->used); - ckfree((char *) byteArrayPtr); - byteArrayPtr = newByteArrayPtr; + byteArrayPtr = (ByteArray *) ckrealloc( + (char *) byteArrayPtr, BYTEARRAY_SIZE(length)); + byteArrayPtr->allocated = length; SET_BYTEARRAY(objPtr, byteArrayPtr); } Tcl_InvalidateStringRep(objPtr); |