[PATCH xserver] xkb: Release XKB component names when compiling keymap.

Peter Hutterer peter.hutterer at who-t.net
Tue Mar 15 19:43:33 PDT 2011


On Fri, Mar 11, 2011 at 02:30:49PM +0200, Rami Ylimäki wrote:
> Reviewed-by: Erkki Seppälä <erkki.seppala at vincit.fi>
> Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
> ---
> I tested this with X server 1.9. However, I did cherry pick enough
> patches from master so that I could make the patch apply cleanly on
> X server master also.

Applied, thanks.

Cheers,
  Peter
> 
>  include/xkbsrv.h |    5 +++++
>  xkb/XKBAlloc.c   |   19 +++++++++++++++++++
>  xkb/ddxLoad.c    |   22 +++++++++++-----------
>  xkb/xkb.c        |   11 +----------
>  4 files changed, 36 insertions(+), 21 deletions(-)
> 
> diff --git a/include/xkbsrv.h b/include/xkbsrv.h
> index 9f1507e..34ef574 100644
> --- a/include/xkbsrv.h
> +++ b/include/xkbsrv.h
> @@ -447,6 +447,11 @@ extern _X_EXPORT void	XkbFreeKeyboard(
>  	Bool			/* freeDesc */
>  );
>  
> +extern _X_EXPORT void	XkbFreeComponentNames(
> +	XkbComponentNamesPtr	/* names */,
> +	Bool			/* freeNames */
> +);
> +
>  extern _X_EXPORT  void XkbSetActionKeyMods(
>  	XkbDescPtr		/* xkb */,
>  	XkbAction *		/* act */,
> diff --git a/xkb/XKBAlloc.c b/xkb/XKBAlloc.c
> index c52e091..87f8a5a 100644
> --- a/xkb/XKBAlloc.c
> +++ b/xkb/XKBAlloc.c
> @@ -335,3 +335,22 @@ XkbFreeKeyboard(XkbDescPtr xkb,unsigned which,Bool freeAll)
>  	free(xkb);
>      return;
>  }
> +
> +
> +/***====================================================================***/
> +
> +void
> +XkbFreeComponentNames(XkbComponentNamesPtr names, Bool freeNames)
> +{
> +    if (names)
> +    {
> +        free(names->keycodes);
> +        free(names->types);
> +        free(names->compat);
> +        free(names->symbols);
> +        free(names->geometry);
> +        memset(names, 0, sizeof(XkbComponentNamesRec));
> +    }
> +    if (freeNames)
> +        free(names);
> +}
> diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
> index 00ac034..501104e 100644
> --- a/xkb/ddxLoad.c
> +++ b/xkb/ddxLoad.c
> @@ -449,23 +449,23 @@ XkbRMLVOtoKcCGST(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, XkbComponentNamesPtr kccg
>  static XkbDescPtr
>  XkbCompileKeymapForDevice(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, int need)
>  {
> -    XkbDescPtr xkb;
> +    XkbDescPtr xkb = NULL;
>      unsigned int provided;
> -    XkbComponentNamesRec kccgst;
> +    XkbComponentNamesRec kccgst = {0};
>      char name[PATH_MAX];
>  
> -    if (!XkbRMLVOtoKcCGST(dev, rmlvo, &kccgst))
> -        return NULL;
> -
> -    provided = XkbDDXLoadKeymapByNames(dev, &kccgst, XkmAllIndicesMask, need,
> -                                       &xkb, name, PATH_MAX);
> -    if ((need & provided) != need) {
> -        if (xkb) {
> -            XkbFreeKeyboard(xkb, 0, TRUE);
> -            xkb = NULL;
> +    if (XkbRMLVOtoKcCGST(dev, rmlvo, &kccgst)) {
> +        provided = XkbDDXLoadKeymapByNames(dev, &kccgst, XkmAllIndicesMask, need,
> +                                           &xkb, name, PATH_MAX);
> +        if ((need & provided) != need) {
> +            if (xkb) {
> +                XkbFreeKeyboard(xkb, 0, TRUE);
> +                xkb = NULL;
> +            }
>          }
>      }
>  
> +    XkbFreeComponentNames(&kccgst, FALSE);
>      return xkb;
>  }
>  
> diff --git a/xkb/xkb.c b/xkb/xkb.c
> index 39dbab4..bd0512a 100644
> --- a/xkb/xkb.c
> +++ b/xkb/xkb.c
> @@ -5898,16 +5898,7 @@ ProcXkbGetKbdByName(ClientPtr client)
>  	XkbFreeKeyboard(new,XkbAllComponentsMask,TRUE);
>  	new= NULL;
>      }
> -    free(names.keycodes);
> -    names.keycodes = NULL;
> -    free(names.types);
> -    names.types = NULL;
> -    free(names.compat);
> -    names.compat = NULL;
> -    free(names.symbols);
> -    names.symbols = NULL;
> -    free(names.geometry);
> -    names.geometry = NULL;
> +    XkbFreeComponentNames(&names, FALSE);
>      return Success;
>  }
>  
> -- 
> 1.6.3.3
> 


More information about the xorg-devel mailing list