summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/X11/extensions/XKBrules.h12
-rw-r--r--src/maprules.c28
2 files changed, 39 insertions, 1 deletions
diff --git a/include/X11/extensions/XKBrules.h b/include/X11/extensions/XKBrules.h
index 4736056..8580b55 100644
--- a/include/X11/extensions/XKBrules.h
+++ b/include/X11/extensions/XKBrules.h
@@ -191,6 +191,18 @@ extern Bool XkbRF_SetNamesProp(
XkbRF_VarDefsPtr /* var_defs */
);
+/**
+ * @brief Destroy @struct XkbRF_VarDefsRec
+ * @param[in] var_defs - a XkbRF_VarDefsRec to clean up
+ * @param[in] freeVarDefs - if @c True also free the @p var_defs itself
+ *
+ * Frees the memory associated with the @p var_defs. If @p free_var_defs is
+ * @c True also frees the @p var_defs pointer itself.
+ */
+extern void XkbRF_FreeVarDefs(
+ XkbRF_VarDefsPtr /* var_defs */,
+ Bool /* freeVarDefs */
+);
_XFUNCPROTOEND
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);
+}