dlls/kernel32/task.c -- add a comment and sizeof

Gerald Pfeifer gerald at pfeifer.com
Sun Feb 24 09:12:07 CST 2008


This is a subset of a patch originally sent some two months ago.
We agree to not take the actual code changes, but it would be nice
to get the comment and sizeof changes in to clarify the code.

Thanks,
Gerald

ChangeLog:
Use 4*sizeof(WORD) instead of the magic constant 8 for THUNKS.thunks,
and explain why we cannot use an open array type THUNKS.thunks[].

Index: dlls/kernel32/task.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel32/task.c,v
retrieving revision 1.2
diff -u -3 -p -r1.2 task.c
--- dlls/kernel32/task.c	13 Oct 2006 10:27:19 -0000	1.2
+++ dlls/kernel32/task.c	6 Jan 2008 12:26:32 -0000
@@ -57,7 +57,10 @@ typedef struct
     WORD  magic;      /* Thunks signature */
     WORD  unused;
     WORD  free;       /* Head of the free list */
-    WORD  thunks[4];  /* Each thunk is 4 words long */
+    WORD  thunks[4];  /* Each thunk is 4 words long, and while we will
+                       * dynamically allocate the whole struct according
+                       * to the actual number of thunks we cannot use the
+                       * thunks[] syntax here because it is not C90. */
 } THUNKS;
 
 #include "poppack.h"
@@ -174,7 +177,7 @@ static void TASK_CreateThunks( HGLOBAL16
     free = pThunk->free;
     for (i = 0; i < count-1; i++)
     {
-        free += 8;  /* Offset of next thunk */
+        free += 4*sizeof(WORD);  /* Offset of next thunk */
         pThunk->thunks[4*i] = free;
     }
     pThunk->thunks[4*i] = 0;  /* Last thunk */
@@ -201,7 +204,8 @@ 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,
+                                sizeof(THUNKS) + (MIN_THUNKS-1)*4*sizeof(WORD),
                                 pTask->hPDB, WINE_LDT_FLAGS_CODE );
             if (!sel) return (SEGPTR)0;
             TASK_CreateThunks( sel, 0, MIN_THUNKS );




More information about the wine-patches mailing list