Patch from Tapani Pälli to fix a memory leak in X11_InitKeyboard
authorSam Lantinga <slouken@libsdl.org>
Tue, 01 Nov 2016 10:48:59 -0700
changeset 105699429d331668e
parent 10568 0cbc922ef093
child 10570 251691cfeaa0
Patch from Tapani Pälli to fix a memory leak in X11_InitKeyboard

Patch uses XkbFreeKeyboard to free the memory returned by XkbGetMap.
Earlier implementation called XkbFreeClientMap which frees all the maps
but not data->xkb structure itself, XkbFreeKeyboard will free maps and
the structure.
src/video/x11/SDL_x11keyboard.c
src/video/x11/SDL_x11sym.h
     1.1 --- a/src/video/x11/SDL_x11keyboard.c	Tue Nov 01 10:46:47 2016 -0700
     1.2 +++ b/src/video/x11/SDL_x11keyboard.c	Tue Nov 01 10:48:59 2016 -0700
     1.3 @@ -484,7 +484,7 @@
     1.4  
     1.5  #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
     1.6      if (data->xkb) {
     1.7 -        X11_XkbFreeClientMap(data->xkb, 0, True);
     1.8 +        X11_XkbFreeKeyboard(data->xkb, 0, True);
     1.9          data->xkb = NULL;
    1.10      }
    1.11  #endif
     2.1 --- a/src/video/x11/SDL_x11sym.h	Tue Nov 01 10:46:47 2016 -0700
     2.2 +++ b/src/video/x11/SDL_x11sym.h	Tue Nov 01 10:48:59 2016 -0700
     2.3 @@ -179,6 +179,7 @@
     2.4  SDL_X11_SYM(Status,XkbGetUpdatedMap,(Display* a,unsigned int b,XkbDescPtr c),(a,b,c),return)
     2.5  SDL_X11_SYM(XkbDescPtr,XkbGetMap,(Display* a,unsigned int b,unsigned int c),(a,b,c),return)
     2.6  SDL_X11_SYM(void,XkbFreeClientMap,(XkbDescPtr a,unsigned int b, Bool c),(a,b,c),)
     2.7 +SDL_X11_SYM(void,XkbFreeKeyboard,(XkbDescPtr a,unsigned int b, Bool c),(a,b,c),)
     2.8  SDL_X11_SYM(BOOL,XkbSetDetectableAutoRepeat,(Display* a, BOOL b, BOOL* c),(a,b,c),return)
     2.9  #endif
    2.10