diff options
author | Rami Ylimäki <rami.ylimaki@vincit.fi> | 2011-03-11 14:30:49 +0200 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@apple.com> | 2011-03-27 22:35:23 -0700 |
commit | e22497eddc54967e892fbe99f2c4239b4504daf6 (patch) | |
tree | 4259a6888b758fe874203e75cbeac79e332718fe | |
parent | a96fd08b406b9955ff0d5c02f4a50f4fb2acf40e (diff) |
xkb: Release XKB component names when compiling keymap.
Reviewed-by: Erkki Seppälä <erkki.seppala@vincit.fi>
Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 5c47f8beac7f87680c6f7331483b9cf94a1dbc86)
-rw-r--r-- | include/xkbsrv.h | 5 | ||||
-rw-r--r-- | xkb/XKBAlloc.c | 19 | ||||
-rw-r--r-- | xkb/ddxLoad.c | 22 | ||||
-rw-r--r-- | xkb/xkb.c | 11 |
4 files changed, 36 insertions, 21 deletions
diff --git a/include/xkbsrv.h b/include/xkbsrv.h index 9f1507e8e..34ef5745e 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 bffd60fce..b70ac1705 100644 --- a/xkb/XKBAlloc.c +++ b/xkb/XKBAlloc.c @@ -333,3 +333,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 ac587fc9d..a93569846 100644 --- a/xkb/ddxLoad.c +++ b/xkb/ddxLoad.c @@ -446,23 +446,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; } @@ -5897,16 +5897,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; } |