A bug in WIN_SetWindowLong ?

eric pouech eric.pouech at wanadoo.fr
Sat Aug 11 03:04:50 CDT 2001


Marco Bizzarri wrote:
> 
> Hi all.
> 
> While debugging some program, I discovered what looks like a bug. Please
> be patient if I'm wrong.
> 
> In the WIN_SetWindowLong function, in order to get the address of
> wExtra, there is:
> 
>          ptr = (LONG *)(((char *)wndPtr->wExtra) + offset);
> 
> but this takes the *CONTENT* of wndPtr->wExtra.
> 
> The correct code should be
> 
>          ptr = (LONG *)(((char *)&wndPtr->wExtra) + offset);
> 
> Am I wrong ?
yes... and no...

as wExtra is defined in struct WND (include/win.h) as
    DWORD          wExtra[1];     /* Window extra bytes */   
wndPtr->wExtra is the address of first byte of extra data, which is what
we want
but, in this case wndPtr->wExtra and &wndPtr->wExtra are the same
beast...
(except for the type, wndPtr->wExtra is a pointer to a DWORD whereas
&wndPtr->wExtra is a pointer to an array of one DWORD...)

A+                                                                                                                     
-- 
---------------
Eric Pouech (http://perso.wanadoo.fr/eric.pouech/)
"The future will be better tomorrow", Vice President Dan Quayle




More information about the wine-users mailing list