[PATCH] xkb: Add XkbFreeRMLVOSet helper function.

Peter Hutterer peter.hutterer at who-t.net
Thu Apr 16 00:06:33 PDT 2009


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 include/xkbsrv.h |    5 +++++
 xkb/xkbInit.c    |   30 +++++++++++++++++++-----------
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 8a81431..df33085 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -858,6 +858,11 @@ extern _X_EXPORT void	XkbGetRulesDflts(
         XkbRMLVOSet *           /* rmlvo */
 );
 
+extern _X_EXPORT void   XkbFreeRMLVOSet(
+        XkbRMLVOSet *           /* rmlvo */,
+        Bool                    /* freeRMLVO */
+);
+
 extern _X_EXPORT void	XkbSetRulesDflts(
         XkbRMLVOSet *           /* rmlvo */
 );
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 9d4d9a2..5ac06fe 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -136,6 +136,24 @@ XkbGetRulesDflts(XkbRMLVOSet *rmlvo)
     rmlvo->options = strdup(rmlvo->options);
 }
 
+void
+XkbFreeRMLVOSet(XkbRMLVOSet *rmlvo, Bool freeRMLVO)
+{
+    if (!rmlvo)
+        return;
+
+    xfree(rmlvo->rules);
+    xfree(rmlvo->model);
+    xfree(rmlvo->layout);
+    xfree(rmlvo->variant);
+    xfree(rmlvo->options);
+
+    if (freeRMLVO)
+        xfree(rmlvo);
+    else
+        memset(rmlvo, 0, sizeof(XkbRMLVOSet));
+}
+
 static Bool
 XkbWriteRulesProp(ClientPtr client, pointer closure)
 {
@@ -595,17 +613,7 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet *rmlvo,
 
     XkbSetRulesDflts(rmlvo);
     XkbSetRulesUsed(rmlvo);
-
-    if (rmlvo_dflts.rules)
-        xfree(rmlvo_dflts.rules);
-    if (rmlvo_dflts.model)
-        xfree(rmlvo_dflts.model);
-    if (rmlvo_dflts.layout)
-        xfree(rmlvo_dflts.layout);
-    if (rmlvo_dflts.variant)
-        xfree(rmlvo_dflts.variant);
-    if (rmlvo_dflts.options)
-        xfree(rmlvo_dflts.options);
+    XkbFreeRMLVOSet(&rmlvo_dflts, FALSE);
 
     return TRUE;
 
-- 
1.6.2.2.447.g4afa7



More information about the xorg-devel mailing list