st/dri: fix optionCache memory leaks
authorMarcin Slusarz <marcin.slusarz@gmail.com>
Mon, 18 Jan 2010 17:48:06 +0000 (10:48 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 18 Jan 2010 17:48:06 +0000 (10:48 -0700)
Signed-off-by: Brian Paul <brianp@vmware.com>
src/gallium/state_trackers/dri/dri_context.c
src/gallium/state_trackers/dri/dri_screen.c

index 8819936fcaf13127659854e46dfe2ddc01070395..cd9d8b682eb7056a886f74ec8aafca030abcad8f 100644 (file)
@@ -101,6 +101,12 @@ dri_destroy_context(__DRIcontextPrivate * cPriv)
 {
    struct dri_context *ctx = dri_context(cPriv);
 
+   /* note: we are freeing values and nothing more because
+    * driParseConfigFiles allocated values only - the rest
+    * is owned by screen optionCache.
+    */
+   FREE(ctx->optionCache.values);
+
    /* No particular reason to wait for command completion before
     * destroying a context, but it is probably worthwhile flushing it
     * to avoid having to add code elsewhere to cope with flushing a
index 11ea28bcbe8312e74031fcca3c73318f9b75c38a..d95c62745e6c0508262b0c8149edd7550ad5912b 100644 (file)
@@ -327,8 +327,18 @@ static void
 dri_destroy_screen(__DRIscreenPrivate * sPriv)
 {
    struct dri_screen *screen = dri_screen(sPriv);
+   int i;
 
    screen->pipe_screen->destroy(screen->pipe_screen);
+   
+   for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) {
+      FREE(screen->optionCache.info[i].name);
+      FREE(screen->optionCache.info[i].ranges);
+   }
+
+   FREE(screen->optionCache.info);
+   FREE(screen->optionCache.values);
+
    FREE(screen);
    sPriv->private = NULL;
 }