summaryrefslogtreecommitdiffstats
path: root/generic/tclBinary.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2018-10-09 18:12:41 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2018-10-09 18:12:41 (GMT)
commit89d6aec1f9a89843d06ff6a562607602995adce8 (patch)
treeedaad5eadc594629b694d0531d9fd500b3dd9846 /generic/tclBinary.c
parent617405c0232699c84da92eea278b40640fc011d9 (diff)
parentfed4d43bd565b34a6cf5cc7da2484f7db6fe9c42 (diff)
downloadtcl-89d6aec1f9a89843d06ff6a562607602995adce8.zip
tcl-89d6aec1f9a89843d06ff6a562607602995adce8.tar.gz
tcl-89d6aec1f9a89843d06ff6a562607602995adce8.tar.bz2
Merge 8.7
Add Unsigned functions to the implementation. TIP text is still far behind describing what's going on here.
Diffstat (limited to 'generic/tclBinary.c')
-rw-r--r--generic/tclBinary.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c
index 0fb6722..6ee3a51 100644
--- a/generic/tclBinary.c
+++ b/generic/tclBinary.c
@@ -268,9 +268,9 @@ const Tcl_ObjType tclByteArrayType = {
*/
typedef struct ByteArray {
- unsigned int used; /* The number of bytes used in the byte
+ int used; /* The number of bytes used in the byte
* array. */
- unsigned int allocated; /* The amount of space actually allocated
+ int allocated; /* The amount of space actually allocated
* minus 1 byte. */
unsigned char bytes[1]; /* The array of bytes. The actual size of this
* field depends on the 'allocated' field
@@ -278,7 +278,7 @@ typedef struct ByteArray {
} ByteArray;
#define BYTEARRAY_SIZE(len) \
- (TclOffset(ByteArray, bytes) + (len))
+ ((unsigned) (TclOffset(ByteArray, bytes) + (len)))
#define GET_BYTEARRAY(objPtr) \
((ByteArray *) (objPtr)->internalRep.twoPtrValue.ptr1)
#define SET_BYTEARRAY(objPtr, baPtr) \
@@ -478,7 +478,11 @@ Tcl_GetByteArrayFromObj2(
baPtr = GET_BYTEARRAY(objPtr);
if (lengthPtr != NULL) {
+#if TCL_MAJOR_VERSION > 8
*lengthPtr = baPtr->used;
+#else
+ *lengthPtr = (unsigned)baPtr->used;
+#endif
}
return (unsigned char *) baPtr->bytes;
}
@@ -521,7 +525,7 @@ Tcl_SetByteArrayLength(
}
byteArrayPtr = GET_BYTEARRAY(objPtr);
- if ((size_t)length > byteArrayPtr->allocated) {
+ if (length > byteArrayPtr->allocated) {
byteArrayPtr = ckrealloc(byteArrayPtr, BYTEARRAY_SIZE(length));
byteArrayPtr->allocated = length;
SET_BYTEARRAY(objPtr, byteArrayPtr);
@@ -739,7 +743,7 @@ TclAppendBytesToByteArray(
int len)
{
ByteArray *byteArrayPtr;
- size_t needed;
+ int needed;
if (Tcl_IsShared(objPtr)) {
Tcl_Panic("%s called with shared object","TclAppendBytesToByteArray");
@@ -758,7 +762,7 @@ TclAppendBytesToByteArray(
}
byteArrayPtr = GET_BYTEARRAY(objPtr);
- if ((size_t)len + byteArrayPtr->used > INT_MAX) {
+ if (len > INT_MAX - byteArrayPtr->used) {
Tcl_Panic("max size for a Tcl value (%d bytes) exceeded", INT_MAX);
}