diff options
author | Alexander Golubev <fatzer2@gmail.com> | 2024-03-17 03:51:37 +0300 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2024-03-18 11:24:46 +1000 |
commit | 6afd4ae4473e7c1701ae3be9813ca2857395f2a5 (patch) | |
tree | ff35b9714594565237729334a6eb742eab3dab4d /src | |
parent | 893788c14a36a7a524659652f0f41439b583bd3d (diff) |
Add XkbRF_FreeVarDefs() a destructor for XkbRF_VarDefsRec.
The function properly frees memory allocated for XkbRF_VarDefsRec by
XkbRF_GetNamesProp().
Based on original contribution by Martin Weber <martin.weber@secunet.com>
Closes: https://gitlab.freedesktop.org/xorg/lib/libxkbfile/-/issues/6
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/maprules.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/maprules.c b/src/maprules.c index bd83f71..7e5bbd5 100644 --- a/src/maprules.c +++ b/src/maprules.c @@ -1458,7 +1458,10 @@ XkbRF_GetNamesProp(Display * dpy, char **rf_rtrn, XkbRF_VarDefsPtr vd_rtrn) vd_rtrn->options = _XkbDupString(out); out += strlen(out) + 1; } - + /* + * For now extra_options and extra_rules are not used + * update XkbRF_FreeVarDefs if that changes + */ XFree(data); return True; } @@ -1528,3 +1531,26 @@ XkbRF_SetNamesProp(Display *dpy, char *rules_file, XkbRF_VarDefsPtr var_defs) return True; } +void +XkbRF_FreeVarDefs(XkbRF_VarDefsPtr var_defs, Bool freeVarDefs) +{ + if (!var_defs) + return; + + _XkbFree(var_defs->model); + var_defs->model = NULL; + _XkbFree(var_defs->layout); + var_defs->layout = NULL; + _XkbFree(var_defs->variant); + var_defs->variant = NULL; + _XkbFree(var_defs->options); + var_defs->options = NULL; + + _XkbFree(var_defs->extra_names); + var_defs->extra_names = NULL; + _XkbFree(var_defs->extra_values); + var_defs->extra_values = NULL; + + if(freeVarDefs) + _XkbFree(var_defs); +} |