Attachment "3129448.patch" to
ticket [3129448fff]
added by
nijtmans
2010-12-06 15:46:40.
### Eclipse Workspace Patch 1.0
#P tcl8.6
Index: generic/tclBinary.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclBinary.c,v
retrieving revision 1.67
diff -u -r1.67 tclBinary.c
--- generic/tclBinary.c 19 Nov 2010 10:17:22 -0000 1.67
+++ generic/tclBinary.c 6 Dec 2010 08:30:45 -0000
@@ -174,13 +174,13 @@
* array. */
int allocated; /* The amount of space actually allocated
* minus 1 byte. */
- unsigned char bytes[4]; /* The array of bytes. The actual size of this
+ unsigned char bytes[1]; /* The array of bytes. The actual size of this
* field depends on the 'allocated' field
* above. */
} ByteArray;
#define BYTEARRAY_SIZE(len) \
- ((unsigned) (sizeof(ByteArray) - 4 + (len)))
+ ((unsigned) (TclOffset(ByteArray, bytes) + (len)))
#define GET_BYTEARRAY(objPtr) \
((ByteArray *) (objPtr)->internalRep.otherValuePtr)
#define SET_BYTEARRAY(objPtr, baPtr) \
Index: generic/tclCkalloc.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclCkalloc.c,v
retrieving revision 1.41
diff -u -r1.41 tclCkalloc.c
--- generic/tclCkalloc.c 1 Dec 2010 10:43:36 -0000 1.41
+++ generic/tclCkalloc.c 6 Dec 2010 08:30:45 -0000
@@ -32,12 +32,12 @@
typedef struct MemTag {
int refCount; /* Number of mem_headers referencing this
* tag. */
- char string[4]; /* Actual size of string will be as large as
+ char string[1]; /* Actual size of string will be as large as
* needed for actual tag. This must be the
* last field in the structure. */
} MemTag;
-#define TAG_SIZE(bytesInString) ((unsigned) sizeof(MemTag) + bytesInString - 3)
+#define TAG_SIZE(bytesInString) ((unsigned) ((TclOffset(MemTag, string) + 1) + bytesInString))
static MemTag *curTagPtr = NULL;/* Tag to use in all future mem_headers (set
* by "memory tag" command). */
Index: generic/tclTrace.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclTrace.c,v
retrieving revision 1.60
diff -u -r1.60 tclTrace.c
--- generic/tclTrace.c 22 Aug 2010 18:53:26 -0000 1.60
+++ generic/tclTrace.c 6 Dec 2010 08:30:45 -0000
@@ -24,11 +24,11 @@
int flags; /* Operations for which Tcl command is to be
* invoked. */
size_t length; /* Number of non-NUL chars. in command. */
- char command[4]; /* Space for Tcl command to invoke. Actual
+ char command[1]; /* Space for Tcl command to invoke. Actual
* size will be as large as necessary to hold
* command. This field must be the last in the
- * structure, so that it can be larger than 4
- * bytes. */
+ * structure, so that it can be larger than 1
+ * byte. */
} TraceVarInfo;
typedef struct {
@@ -58,11 +58,11 @@
* deleted too early. Keeps track of how many
* pieces of code have a pointer to this
* structure. */
- char command[4]; /* Space for Tcl command to invoke. Actual
+ char command[1]; /* Space for Tcl command to invoke. Actual
* size will be as large as necessary to hold
* command. This field must be the last in the
- * structure, so that it can be larger than 4
- * bytes. */
+ * structure, so that it can be larger than 1
+ * byte. */
} TraceCommandInfo;
/*
@@ -464,9 +464,8 @@
length = (size_t) commandLength;
if ((enum traceOptions) optionIndex == TRACE_ADD) {
TraceCommandInfo *tcmdPtr = (TraceCommandInfo *)
- ckalloc((unsigned) (sizeof(TraceCommandInfo)
- - sizeof(tcmdPtr->command) + length + 1));
-
+ ckalloc((unsigned) ((TclOffset(TraceCommandInfo, command)
+ + 1) + length));
tcmdPtr->flags = flags;
tcmdPtr->stepTrace = NULL;
tcmdPtr->startLevel = 0;
@@ -701,8 +700,8 @@
length = (size_t) commandLength;
if ((enum traceOptions) optionIndex == TRACE_ADD) {
TraceCommandInfo *tcmdPtr = (TraceCommandInfo *)
- ckalloc((unsigned) (sizeof(TraceCommandInfo)
- - sizeof(tcmdPtr->command) + length + 1));
+ ckalloc((unsigned) ((TclOffset(TraceCommandInfo, command)
+ + 1) + length));
tcmdPtr->flags = flags;
tcmdPtr->stepTrace = NULL;
@@ -902,8 +901,8 @@
length = (size_t) commandLength;
if ((enum traceOptions) optionIndex == TRACE_ADD) {
CombinedTraceVarInfo *ctvarPtr = (CombinedTraceVarInfo *)
- ckalloc((unsigned) (sizeof(CombinedTraceVarInfo)
- + length + 1 - sizeof(ctvarPtr->traceCmdInfo.command)));
+ ckalloc((unsigned) ((TclOffset(CombinedTraceVarInfo,
+ traceCmdInfo.command) + 1) + length));
ctvarPtr->traceCmdInfo.flags = flags;
if (objv[0] == NULL) {