diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-10-03 08:11:48 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-10-03 08:11:48 (GMT) |
commit | d7fd32ebdc04976287c78247d664efa442b3c5fe (patch) | |
tree | 15adf3c75d8eed679221308126e83de6e2bfb15d /generic/tclBinary.c | |
parent | 948410d3929a4818d0fe0c6b7dfd918e4a98f35f (diff) | |
parent | 301282088d6b7961c502f111c171db6e6a341ab9 (diff) | |
download | tcl-d7fd32ebdc04976287c78247d664efa442b3c5fe.zip tcl-d7fd32ebdc04976287c78247d664efa442b3c5fe.tar.gz tcl-d7fd32ebdc04976287c78247d664efa442b3c5fe.tar.bz2 |
merge trunk
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r-- | generic/tclBinary.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c index a1e836e..3d8b24c 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -303,18 +303,16 @@ Tcl_SetByteArrayObj( TclFreeIntRep(objPtr); Tcl_InvalidateStringRep(objPtr); - length = (length < 0) ? 0 : length; + if (length < 0) { + length = 0; + } byteArrayPtr = ckalloc(BYTEARRAY_SIZE(length)); byteArrayPtr->used = length; byteArrayPtr->allocated = length; - if (length) { - if (bytes) { - memcpy(byteArrayPtr->bytes, bytes, (size_t) length); - } else { - memset(byteArrayPtr->bytes, 0, (size_t) length); - } - } + if ((bytes != NULL) && (length > 0)) { + memcpy(byteArrayPtr->bytes, bytes, (size_t) length); + } objPtr->typePtr = &tclByteArrayType; SET_BYTEARRAY(objPtr, byteArrayPtr); } |