dummy (or not) question about AllocateWindow ()

Carlos Eduardo Rodrigues Diógenes cerdiogenes at yahoo.com.br
Sun Jun 25 06:44:05 PDT 2006


On Fri, 2006-06-23 at 11:25 -0400, Adam Jackson wrote:
> 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.

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?

> 
> We then change the type of that pointer from WindowPtr to DevUnion *, and 
> assign it to ppriv.
> 
> - ajax
-- 
Carlos Eduardo Rodrigues Diógenes
Projeto xLupa - http://www.unioeste.br/projetos/xlupa




More information about the xorg mailing list