g3dvl: Fix some memory leaks in the winsys.
authorYounes Manton <younes.m@gmail.com>
Sat, 19 Jul 2008 20:22:56 +0000 (16:22 -0400)
committerYounes Manton <younes.m@gmail.com>
Sun, 20 Jul 2008 23:16:41 +0000 (19:16 -0400)
src/gallium/state_trackers/g3dvl/vl_context.c
src/gallium/winsys/g3dvl/xsp_winsys.c
src/gallium/winsys/g3dvl/xsp_winsys.h
src/libXvMC/context.c

index 1668ad1..3d4ca7c 100644 (file)
@@ -2208,8 +2208,6 @@ int vlDestroyContext(struct VL_CONTEXT *context)
        
        vlDestroy(context);
        
-       context->pipe->destroy(context->pipe);
-       
        free(context);
        
        return 0;
index 7c5c592..c660c6e 100644 (file)
@@ -224,8 +224,8 @@ static const char* xsp_get_name(struct pipe_winsys *pws)
 struct pipe_context* create_pipe_context(Display *display)
 {
        struct xsp_pipe_winsys  *xsp_winsys;
-       struct pipe_screen      *p_screen;
-       struct pipe_context     *p_context;
+       struct pipe_screen      *screen;
+       struct pipe_context     *pipe;
        
        assert(display);
        
@@ -269,9 +269,25 @@ struct pipe_context* create_pipe_context(Display *display)
                XDestroyImage(template);
        }
        
-       p_screen = softpipe_create_screen((struct pipe_winsys*)xsp_winsys);
-       p_context = softpipe_create(p_screen, (struct pipe_winsys*)xsp_winsys, NULL);
+       screen = softpipe_create_screen((struct pipe_winsys*)xsp_winsys);
+       pipe = softpipe_create(screen, (struct pipe_winsys*)xsp_winsys, NULL);
        
-       return p_context;
+       return pipe;
+}
+
+int destroy_pipe_context(struct pipe_context *pipe)
+{
+       struct pipe_screen *screen;
+       struct pipe_winsys *winsys;
+       
+       assert(pipe);
+       
+       screen = pipe->screen;
+       winsys = pipe->winsys;
+       pipe->destroy(pipe);
+       screen->destroy(screen);
+       free(winsys);
+       
+       return 0;
 }
 
index 47a6ac6..cb163dc 100644 (file)
@@ -6,6 +6,7 @@
 struct pipe_context;
 
 struct pipe_context* create_pipe_context(Display *display);
+int destroy_pipe_context(struct pipe_context *pipe);
 
 #endif
 
index c835a6a..e559002 100644 (file)
@@ -136,7 +136,8 @@ Status XvMCCreateContext(Display *display, XvPortID port, int surface_type_id, i
 
 Status XvMCDestroyContext(Display *display, XvMCContext *context)
 {
-       struct VL_CONTEXT *vl_ctx;
+       struct VL_CONTEXT       *vl_ctx;
+       struct pipe_context     *pipe;
        
        assert(display);
        
@@ -147,7 +148,9 @@ Status XvMCDestroyContext(Display *display, XvMCContext *context)
        
        assert(display == vl_ctx->display);
        
+       pipe = vl_ctx->pipe;
        vlDestroyContext(vl_ctx);
+       destroy_pipe_context(pipe);
        
        return Success;
 }