diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-10-17 13:52:24 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-10-17 13:52:24 (GMT) |
commit | a9804776bdfcb5ebbddabaac09423e630f6c6452 (patch) | |
tree | 118f7c7682cdbaf9666f25c8fae9b7e912d55892 /generic/tclBinary.c | |
parent | ef03a2c7809309b2255f7c82c6abe0db2e4160bf (diff) | |
parent | 4bb1f92d128bf8ca978c59204d2636685d13e769 (diff) | |
download | tcl-a9804776bdfcb5ebbddabaac09423e630f6c6452.zip tcl-a9804776bdfcb5ebbddabaac09423e630f6c6452.tar.gz tcl-a9804776bdfcb5ebbddabaac09423e630f6c6452.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); } |