Free all atoms along with keymap
authorRan Benita <ran234@gmail.com>
Thu, 1 Mar 2012 18:41:34 +0000 (20:41 +0200)
committerRan Benita <ran234@gmail.com>
Sat, 3 Mar 2012 22:04:04 +0000 (00:04 +0200)
The code to do this is taken from xserver, dix/atom.c.

Signed-off-by: Ran Benita <ran234@gmail.com>
src/atom.c
src/xkbcomp/xkbcomp.c
src/xkbmisc.h

index 8f9aa0d..09ff9ad 100644 (file)
@@ -215,3 +215,26 @@ xkb_intern_atom(const char *string)
     else
         return None;
 }
+
+static void
+FreeAtom(NodePtr patom)
+{
+    if (patom->left)
+        FreeAtom(patom->left);
+    if (patom->right)
+        FreeAtom(patom->right);
+    free(patom->string);
+    free(patom);
+}
+
+void
+XkbcFreeAllAtoms(void)
+{
+    if (atomRoot == NULL)
+        return;
+    FreeAtom(atomRoot);
+    atomRoot = NULL;
+    free(nodeTable);
+    nodeTable = NULL;
+    lastAtom = None;
+}
index 50d3707..cee6856 100644 (file)
@@ -29,6 +29,7 @@ authorization from the authors.
 #include "xkballoc.h"
 #include "xkbrules.h"
 #include "xkbpath.h"
+#include "xkbmisc.h"
 #include "parseutils.h"
 #include "utils.h"
 
@@ -315,4 +316,5 @@ void
 xkb_free_keymap(struct xkb_desc *xkb)
 {
     XkbcFreeKeyboard(xkb);
+    XkbcFreeAllAtoms();
 }
index 40f1334..4673f0d 100644 (file)
@@ -70,6 +70,9 @@ XkbcNameMatchesPattern(char *name, char *ptrn);
 extern char *
 XkbcAtomGetString(uint32_t atom);
 
+extern void
+XkbcFreeAllAtoms(void);
+
 /***====================================================================***/
 
 extern const char *