[PATCH 3/9] xkb: free XkbRulesUsed and XkbRulesDflt on extension cleanup

Peter Hutterer peter.hutterer at who-t.net
Mon Feb 27 16:41:00 PST 2012


==2547== 1 bytes in 1 blocks are still reachable in loss record 1 of 111
==2547==    at 0x4C2A4CD: malloc (vg_replace_malloc.c:236)
==2547==    by 0x64D1551: strdup (strdup.c:43)
==2547==    by 0x4802FB: Xstrdup (utils.c:1113)
==2547==    by 0x585B6C: XkbSetRulesUsed (xkbInit.c:219)
==2547==    by 0x58700F: InitKeyboardDeviceStruct (xkbInit.c:595)
==2547==    by 0x419FA3: vfbKeybdProc (InitInput.c:74)
==2547==    by 0x425A3D: ActivateDevice (devices.c:540)
==2547==    by 0x425F65: InitAndStartDevices (devices.c:713)
==2547==    by 0x5ACA57: main (main.c:259)

and a few more of the above.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 include/xkbsrv.h |    4 ++++
 xkb/xkb.c        |    9 ++++++++-
 xkb/xkbInit.c    |   15 +++++++++++++++
 3 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 7b00534..5e29033 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -841,6 +841,10 @@ extern _X_EXPORT void	XkbDeleteRulesDflts(
 	void
 );
 
+extern _X_EXPORT void	XkbDeleteRulesUsed(
+	void
+);
+
 extern _X_EXPORT int SProcXkbDispatch(
 	ClientPtr		/* client */
 );
diff --git a/xkb/xkb.c b/xkb/xkb.c
index ac0b427..ed7c26d 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -6685,6 +6685,13 @@ XkbClientGone(pointer data,XID id)
     return 1;
 }
 
+static void
+XkbExtensionCloseDown(ExtensionEntry *extEntry)
+{
+    XkbDeleteRulesUsed();
+    XkbDeleteRulesDflts();
+}
+
 void
 XkbExtensionInit(void)
 {
@@ -6699,7 +6706,7 @@ XkbExtensionInit(void)
 
     if ((extEntry = AddExtension(XkbName, XkbNumberEvents, XkbNumberErrors,
 				 ProcXkbDispatch, SProcXkbDispatch,
-				 NULL, StandardMinorOpcode))) {
+				 XkbExtensionCloseDown, StandardMinorOpcode))) {
 	XkbReqCode = (unsigned char)extEntry->base;
 	XkbEventBase = (unsigned char)extEntry->eventBase;
 	XkbErrorBase = (unsigned char)extEntry->errorBase;
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index f578f16..a665e5a 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -251,6 +251,21 @@ XkbSetRulesDflts(XkbRMLVOSet *rmlvo)
 }
 
 void
+XkbDeleteRulesUsed(void)
+{
+    free(XkbRulesUsed);
+    XkbRulesUsed = NULL;
+    free(XkbModelUsed);
+    XkbModelUsed = NULL;
+    free(XkbLayoutUsed);
+    XkbLayoutUsed = NULL;
+    free(XkbVariantUsed);
+    XkbVariantUsed = NULL;
+    free(XkbOptionsUsed);
+    XkbOptionsUsed = NULL;
+}
+
+void
 XkbDeleteRulesDflts(void)
 {
     free(XkbRulesDflt);
-- 
1.7.7.6



More information about the xorg-devel mailing list