dummy (or not) question about AllocateWindow ()

Adam Jackson ajax at nwnk.net
Fri Jun 23 08:25:34 PDT 2006


On Wednesday 21 June 2006 13:52, Carlos Eduardo Rodrigues Diógenes wrote:
> Hi,
>
> In AllocateWindow () from dix/window.c what this line does:
>
> ppriv = (DevUnion *)(pWin + 1);
>
> It's after the first *if* of the function.
>
> I can't realize this operation. This appear to cast the XID (the 4th
> byte) in DrawableRec (the first struct in _Window) to a DevUnion and
> then make the devPrivate point to the same place.

(pWin + 1) evaluates first.  pWin is a pointer; pointer arithmetic works like 
arrays, incrementing a pointer gives you a pointer to the memory just after 
the object (struct, union, or primitive type) originally pointed to.

We then change the type of that pointer from WindowPtr to DevUnion *, and 
assign it to ppriv.

- ajax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20060623/b05160a6/attachment.pgp>


More information about the xorg mailing list