[Mesa-dev] [PATCH] egl_dri2: do not leak dri2_dpy->driver_configs

Emil Velikov emil.l.velikov at gmail.com
Thu Oct 23 09:27:01 PDT 2014


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 at gmail.com>
---

Hi enpeng xu,

This is a small improvement of your patch that fully cleans-up the 
driver_configs, rather than masking the issue. With this the
indirectly lost: is down to 264 bytes yet 
definitely lost: is still sitting at ~20KiB

Feel free to give it a stab :P

Cheers,
-Emil


 src/egl/drivers/dri2/egl_dri2.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 20a7243..dcc3239 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -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;
 
-- 
2.1.0



More information about the mesa-dev mailing list