From: Peter Hutterer Date: Mon, 27 Feb 2012 08:59:45 +0000 (+1000) Subject: dix: reset the registry before quitting X-Git-Tag: xorg-server-1.14.99.2~86 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d3d4af5f9e505d444b6c82c6ea238206433fd24b;p=platform%2Fupstream%2Fxorg-server.git dix: reset the registry before quitting Heaps of these: ==2042== 15,360 bytes in 120 blocks are still reachable in loss record 94 of 97 ==2042== at 0x4C2A4CD: malloc (vg_replace_malloc.c:236) ==2042== by 0x4C2A657: realloc (vg_replace_malloc.c:525) ==2042== by 0x45FB91: double_size (registry.c:65) ==2042== by 0x45FC97: RegisterRequestName (registry.c:85) ==2042== by 0x460095: RegisterExtensionNames (registry.c:179) ==2042== by 0x460729: dixResetRegistry (registry.c:334) ==2042== by 0x5AC992: main (main.c:201) Signed-off-by: Peter Hutterer Reviewed-by: Keith Packard --- diff --git a/dix/main.c b/dix/main.c index c46e40a..1fa0504 100644 --- a/dix/main.c +++ b/dix/main.c @@ -358,6 +358,8 @@ main(int argc, char *argv[], char *envp[]) dixFreePrivates(serverClient->devPrivates, PRIVATE_CLIENT); serverClient->devPrivates = NULL; + dixFreeRegistry(); + FreeFonts(); FreeAllAtoms(); diff --git a/dix/registry.c b/dix/registry.c index 5bad0fd..82a3340 100644 --- a/dix/registry.c +++ b/dix/registry.c @@ -280,14 +280,9 @@ LookupResourceName(RESTYPE resource) return resources[resource] ? resources[resource] : XREGISTRY_UNKNOWN; } -/* - * Setup and teardown - */ void -dixResetRegistry(void) +dixFreeRegistry(void) { - ExtensionEntry extEntry = { .name = CORE }; - /* Free all memory */ while (nmajor--) { while (nminor[nmajor]) @@ -315,9 +310,23 @@ dixResetRegistry(void) nmajor = nevent = nerror = nresource = 0; + if (fh) { + fclose(fh); + fh = NULL; + } +} + +/* + * Setup and teardown + */ +void +dixResetRegistry(void) +{ + ExtensionEntry extEntry = { .name = CORE }; + + dixFreeRegistry(); + /* Open the protocol file */ - if (fh) - fclose(fh); fh = fopen(FILENAME, "r"); if (!fh) LogMessage(X_WARNING, diff --git a/include/registry.h b/include/registry.h index f471b89..e298ab6 100644 --- a/include/registry.h +++ b/include/registry.h @@ -44,6 +44,7 @@ extern _X_EXPORT const char *LookupResourceName(RESTYPE rtype); * Setup and teardown */ extern _X_EXPORT void dixResetRegistry(void); +extern _X_EXPORT void dixFreeRegistry(void); #else /* XREGISTRY */