dummy (or not) question about AllocateWindow ()
ajax at nwnk.net
Mon Jun 26 08:05:09 PDT 2006
On Sunday 25 June 2006 09:44, Carlos Eduardo Rodrigues Diógenes wrote:
> On Fri, 2006-06-23 at 11:25 -0400, Adam Jackson wrote:
> > (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.
> Thanks for the explanation, but I'm still in troubles with this ;-).
> pWin points to a region of the size pScreen->totalWindowSize, that can
> be bigger than the Window structure or not. So (pWin + 1) can't make
> ppriv points to an incorrect memory position?
totalWindowSize is guaranteed to be no smaller than sizeof(WindowRec). It is
initially sized to be exactly that large (plus padding out to the nearest
multiple of sizeof(long)) in dix/main.c, and then sizeof(DevUnion) is added
to it in dix/privates.c, so when you allocate totalWindowSize bytes, you're
allocating enough for both a WindowRec and a DevUnion. The funny pointer
math is just getting you to the DevUnion at the end.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
More information about the xorg