diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkFont.c | 8 | ||||
-rw-r--r-- | generic/tkText.c | 4 | ||||
-rw-r--r-- | generic/tkText.h | 2 |
3 files changed, 7 insertions, 7 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; |