[PATCH 07/12] dix: add AllocGrab helper function

Peter Hutterer peter.hutterer at who-t.net
Tue Nov 8 01:27:36 PST 2011


On Tue, Nov 08, 2011 at 09:30:33AM +0100, walter harms wrote:
> 
> 
> Am 07.11.2011 22:39, schrieb Peter Hutterer:
> > Not needed since the GrabRec is a self-contained struct but will be needed
> > for the xi2 input mask rework.
> > FreeGrab already exists, make it available to other callers.
> > 
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> >  dix/grabs.c        |   12 ++++++++++--
> >  include/dixgrabs.h |    3 +++
> >  2 files changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/dix/grabs.c b/dix/grabs.c
> > index c28356d..3b07186 100644
> > --- a/dix/grabs.c
> > +++ b/dix/grabs.c
> > @@ -181,6 +181,14 @@ UngrabAllDevices(Bool kill_client)
> >  }
> >  
> >  GrabPtr
> > +AllocGrab(void)
> > +{
> > +    GrabPtr grab = calloc(1, sizeof(GrabRec));
> > +
> > +    return grab;
> > +}
> > +
> 
> 
> nit picking but ...
> 
> any reason not to use return calloc(1, sizeof(GrabRec)); ?
> (as patch 5 does ?)

fair point. this patch was separated so it would apply to master, in my
current tree there are some more lines between allocation and return (which
I removed from the diff for this patch). so yes, I could change this but
it'd only change back once the other grab changes go in.

Cheers,
  Peter

> > +GrabPtr
> >  CreateGrab(
> >      int client,
> >      DeviceIntPtr device,
> > @@ -196,7 +204,7 @@ CreateGrab(
> >  {
> >      GrabPtr grab;
> >  
> > -    grab = calloc(1, sizeof(GrabRec));
> > +    grab = AllocGrab();
> >      if (!grab)
> >  	return (GrabPtr)NULL;
> >      grab->resource = FakeClientID(client);
> > @@ -226,7 +234,7 @@ CreateGrab(
> >  
> >  }
> >  
> > -static void
> > +void
> >  FreeGrab(GrabPtr pGrab)
> >  {
> >      free(pGrab->modifiersDetail.pMask);
> > diff --git a/include/dixgrabs.h b/include/dixgrabs.h
> > index 229c8bb..2ed8a54 100644
> > --- a/include/dixgrabs.h
> > +++ b/include/dixgrabs.h
> > @@ -31,6 +31,9 @@ struct _GrabParameters;
> >  extern void PrintDeviceGrabInfo(DeviceIntPtr dev);
> >  extern void UngrabAllDevices(Bool kill_client);
> >  
> > +extern GrabPtr AllocGrab(void);
> > +extern void FreeGrab(GrabPtr grab);
> > +
> >  extern GrabPtr CreateGrab(
> >  	int /* client */,
> >  	DeviceIntPtr /* device */,


More information about the xorg-devel mailing list