[PATCH 2/2] xkb: strdup the values returned by XkbGetRulesDflts

Peter Hutterer peter.hutterer at who-t.net
Thu Apr 16 17:01:30 PDT 2009


On Wed, Apr 15, 2009 at 10:17:57PM -0700, Dan Nicholson wrote:
> >  static Bool
> > @@ -586,6 +596,17 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet *rmlvo,
> >     XkbSetRulesDflts(rmlvo);
> >     XkbSetRulesUsed(rmlvo);
> >
> > +    if (rmlvo_dflts.rules)
> > +        xfree(rmlvo_dflts.rules);
> > +    if (rmlvo_dflts.model)
> > +        xfree(rmlvo_dflts.model);
> > +    if (rmlvo_dflts.layout)
> > +        xfree(rmlvo_dflts.layout);
> > +    if (rmlvo_dflts.variant)
> > +        xfree(rmlvo_dflts.variant);
> > +    if (rmlvo_dflts.options)
> > +        xfree(rmlvo_dflts.options);
> 
> Can we get a helper for this to make it easier on callers? Something like:
> 
> XkbFreeRMLVO(XkbRMLVOSet *rmlvo, Bool freeRules)
> {
>     if (!rmlvo)
>         return;
> 
>     xfree(rmlvo->rules);
>     xfree(rmlvo->model);
>     xfree(rmlvo->layout);
>     xfree(rmlvo->variant);
>     xfree(rmlvo->options);
> 
>     if (freeRules)
>         xfree(rmlvo);
> }
> 
> I think xfree/Xfree already does the right thing with NULL arguments.

How about this?



More information about the xorg-devel mailing list