g3dvl: Fix some memory leaks.
authorYounes Manton <younes.m@gmail.com>
Fri, 12 Dec 2008 04:04:51 +0000 (23:04 -0500)
committerYounes Manton <younes.m@gmail.com>
Sat, 10 Jan 2009 18:52:06 +0000 (13:52 -0500)
src/driclient/src/driclient.c
src/libXvMC/context.c

index 2d7514166faa4ef4c504be00e985f66d19437e12..dc2189afec3ee7e8dbcf8d8bfba19d75d9c0a1d4 100644 (file)
@@ -111,8 +111,23 @@ free_screen:
 
 int driDestroyScreen(dri_screen_t *dri_screen)
 {
+       Drawable        draw;
+       dri_drawable_t  *dri_draw;
+
        assert(dri_screen);
 
+       if (drmHashFirst(dri_screen->drawable_hash, &draw, (void**)&dri_draw))
+       {
+               dri_draw->refcount = 1;
+               driDestroyDrawable(dri_draw);
+
+               while (drmHashNext(dri_screen->drawable_hash, &draw, (void**)&dri_draw))
+               {
+                       dri_draw->refcount = 1;
+                       driDestroyDrawable(dri_draw);
+               }
+       }
+
        drmHashDestroy(dri_screen->drawable_hash);
        drmUnmap(dri_screen->sarea, SAREA_MAX);
        drmCloseOnce(dri_screen->fd);
index 698410d4c2e77ef6987186eb76e142b8c0e504c0..273f65802928adf0633212ae8edad01092120ddc 100644 (file)
@@ -182,6 +182,8 @@ Status XvMCCreateContext(Display *display, XvPortID port, int surface_type_id, i
 Status XvMCDestroyContext(Display *display, XvMCContext *context)
 {
        struct vlContext        *vl_ctx;
+       struct vlScreen         *vl_screen;
+       struct vlDisplay        *vl_dpy;
        struct pipe_context     *pipe;
 
        assert(display);
@@ -194,7 +196,11 @@ Status XvMCDestroyContext(Display *display, XvMCContext *context)
        assert(display == vlGetNativeDisplay(vlGetDisplay(vlContextGetScreen(vl_ctx))));
 
        pipe = vlGetPipeContext(vl_ctx);
+       vl_screen = vlContextGetScreen(vl_ctx);
+       vl_dpy = vlGetDisplay(vl_screen);
        vlDestroyContext(vl_ctx);
+       vlDestroyScreen(vl_screen);
+       vlDestroyDisplay(vl_dpy);
        destroy_pipe_context(pipe);
 
        return Success;