egl_dri2: do not leak dri2_dpy->driver_configs
authorEmil Velikov <emil.l.velikov@gmail.com>
Thu, 23 Oct 2014 16:27:01 +0000 (17:27 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 6 Nov 2014 13:23:51 +0000 (13:23 +0000)
Walk through the list and free each config, and finally free the list
itself. Freeing approx 20KiB of memory, according to valgrind.
Inspired by a similar patch by enpeng xu.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
src/egl/drivers/dri2/egl_dri2.c

index 20a7243846004ea0d4110b6a174c43bb1b98fbdd..dcc323918eb47e9eb1f58442dd106e85e557c0cd 100644 (file)
@@ -666,6 +666,7 @@ static EGLBoolean
 dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
 {
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+   unsigned i;
 
    _eglReleaseDisplayResources(drv, disp);
    _eglCleanupDisplay(disp);
@@ -706,6 +707,9 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
       break;
    }
 
+   for (i = 0; dri2_dpy->driver_configs[i]; i++)
+      free((__DRIconfig *) dri2_dpy->driver_configs[i]);
+   free(dri2_dpy->driver_configs);
    free(dri2_dpy);
    disp->DriverData = NULL;