diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-10 07:39:03 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-09-10 07:39:03 (GMT) |
commit | cbd1d502879113bb4e0a5dee3a9f2eef2214332a (patch) | |
tree | b98b812fdf3e1233c25dc8dff7c331b07a34b1f0 | |
parent | ce0f0f80b78d67262dfc3270f6b26a042f19141d (diff) | |
download | tk-cbd1d502879113bb4e0a5dee3a9f2eef2214332a.zip tk-cbd1d502879113bb4e0a5dee3a9f2eef2214332a.tar.gz tk-cbd1d502879113bb4e0a5dee3a9f2eef2214332a.tar.bz2 |
More usages for TKFLEXARRAY
-rw-r--r-- | generic/tkFont.c | 8 | ||||
-rw-r--r-- | generic/tkText.c | 4 | ||||
-rw-r--r-- | generic/tkText.h | 2 | ||||
-rw-r--r-- | unix/tkUnixWm.c | 4 | ||||
-rw-r--r-- | win/tkWinWm.c | 4 |
5 files changed, 11 insertions, 11 deletions
diff --git a/generic/tkFont.c b/generic/tkFont.c index 67d0b36..05d75db 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -96,7 +96,7 @@ typedef struct TextLayout { * layout. */ int numChunks; /* Number of chunks actually used in following * array. */ - LayoutChunk chunks[1]; /* Array of chunks. The actual size will be + LayoutChunk chunks[TKFLEXARRAY];/* Array of chunks. The actual size will be * maxChunks. THIS FIELD MUST BE THE LAST IN * THE STRUCTURE. */ } TextLayout; @@ -2002,8 +2002,8 @@ Tk_ComputeTextLayout( maxChunks = 1; - layoutPtr = (TextLayout *)ckalloc(sizeof(TextLayout) - + (maxChunks-1) * sizeof(LayoutChunk)); + layoutPtr = (TextLayout *)ckalloc(offsetof(TextLayout, chunks) + + maxChunks * sizeof(LayoutChunk)); layoutPtr->tkfont = tkfont; layoutPtr->string = string; layoutPtr->numChunks = 0; @@ -3827,7 +3827,7 @@ NewChunk( maxChunks = *maxPtr; if (layoutPtr->numChunks == maxChunks) { maxChunks *= 2; - s = sizeof(TextLayout) + ((maxChunks - 1) * sizeof(LayoutChunk)); + s = offsetof(TextLayout, chunks) + (maxChunks * sizeof(LayoutChunk)); layoutPtr = (TextLayout *)ckrealloc(layoutPtr, s); *layoutPtrPtr = layoutPtr; diff --git a/generic/tkText.c b/generic/tkText.c index 0eb256f..f636549 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -4539,8 +4539,8 @@ TkTextGetTabs( * Parse the elements of the list one at a time to fill in the array. */ - tabArrayPtr = (TkTextTabArray *)ckalloc(sizeof(TkTextTabArray) - + (count - 1) * sizeof(TkTextTab)); + tabArrayPtr = (TkTextTabArray *)ckalloc(offsetof(TkTextTabArray, tabs) + + count * sizeof(TkTextTab)); tabArrayPtr->numTabs = 0; prevStop = 0.0; lastStop = 0.0; diff --git a/generic/tkText.h b/generic/tkText.h index 973ae74..e9e6303 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -489,7 +489,7 @@ typedef struct TkTextTabArray { double tabIncrement; /* The accurate fractional pixel increment * between interpolated tabs we have to create * when we exceed numTabs. */ - TkTextTab tabs[1]; /* Array of tabs. The actual size will be + TkTextTab tabs[TKFLEXARRAY];/* Array of tabs. The actual size will be * numTabs. THIS FIELD MUST BE THE LAST IN THE * STRUCTURE. */ } TkTextTabArray; diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 656c0b7..06d908b 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -27,8 +27,8 @@ typedef struct ProtocolHandler { /* Next in list of protocol handlers for the * same top-level window, or NULL for end of * list. */ - Tcl_Interp *interp; /* Interpreter in which to invoke command. */ - char command[1]; /* Tcl command to invoke when a client message + Tcl_Interp *interp; /* Interpreter in which to invoke command. */ + char command[TKFLEXARRAY]; /* Tcl command to invoke when a client message * for this protocol arrives. The actual size * of the structure varies to accommodate the * needs of the actual command. THIS MUST BE diff --git a/win/tkWinWm.c b/win/tkWinWm.c index d7ac13a..324511a 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -57,8 +57,8 @@ typedef struct ProtocolHandler { /* Next in list of protocol handlers for the * same top-level window, or NULL for end of * list. */ - Tcl_Interp *interp; /* Interpreter in which to invoke command. */ - char command[1]; /* Tcl command to invoke when a client message + Tcl_Interp *interp; /* Interpreter in which to invoke command. */ + char command[TKFLEXARRAY]; /* Tcl command to invoke when a client message * for this protocol arrives. The actual size * of the structure varies to accommodate the * needs of the actual command. THIS MUST BE |