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 1668ad1651b3e7f86941518934a56a69ff104b6a..3d4ca7cf4e29fc74840e82442bec6c1cce8eeead 100644 (file)
@@ -2208,8 +2208,6 @@ int vlDestroyContext(struct VL_CONTEXT *context)
        
        vlDestroy(context);
        
-       context->pipe->destroy(context->pipe);
-       
        free(context);
        
        return 0;
index 7c5c592fc77d028f3285029739aa824acaf363e1..c660c6e0186edaffcfcb8ff8d06d23bb6ca6d09c 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 47a6ac6e251e5943daf83f523247077888b67154..cb163dc24d26eb14d8b987b0e21a675a1ef8c2fa 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 c835a6acf7a45d6f75135465de1f1fff38209154..e5590025777005c71ffd1d2f387f85f99e6fda5e 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;
 }