krnl386.exe16: Use FIELD_OFFSET for the size of structs with varlength arrays
Michael Stefaniuc
mstefani at redhat.de
Fri Nov 16 04:15:06 CST 2012
---
dlls/krnl386.exe16/atom.c | 2 +-
dlls/krnl386.exe16/task.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/krnl386.exe16/atom.c b/dlls/krnl386.exe16/atom.c
index 0c52f1f..a059561 100644
--- a/dlls/krnl386.exe16/atom.c
+++ b/dlls/krnl386.exe16/atom.c
@@ -163,7 +163,7 @@ WORD WINAPI InitAtomTable16( WORD entries )
/* Allocate the table */
if (!entries) entries = DEFAULT_ATOMTABLE_SIZE; /* sanity check */
- handle = LocalAlloc16( LMEM_FIXED, sizeof(ATOMTABLE) + (entries-1) * sizeof(HANDLE16) );
+ handle = LocalAlloc16( LMEM_FIXED, FIELD_OFFSET( ATOMTABLE, entries[entries] ));
if (!handle) return 0;
table = MapSL( MAKESEGPTR( CURRENT_DS, handle ) );
table->size = entries;
diff --git a/dlls/krnl386.exe16/task.c b/dlls/krnl386.exe16/task.c
index b067c81..f3fc56d 100644
--- a/dlls/krnl386.exe16/task.c
+++ b/dlls/krnl386.exe16/task.c
@@ -200,7 +200,7 @@ static SEGPTR TASK_AllocThunk(void)
sel = pThunk->next;
if (!sel) /* Allocate a new segment */
{
- sel = GLOBAL_Alloc( GMEM_FIXED, sizeof(THUNKS) + (MIN_THUNKS-1)*8,
+ sel = GLOBAL_Alloc( GMEM_FIXED, FIELD_OFFSET( THUNKS, thunks[MIN_THUNKS] ),
pTask->hPDB, WINE_LDT_FLAGS_CODE );
if (!sel) return 0;
TASK_CreateThunks( sel, 0, MIN_THUNKS );
--
1.7.7.6
More information about the wine-patches
mailing list