softpipe: fix memory leaks
authorMorgan Armand <morgan.devel@gmail.com>
Mon, 7 Nov 2011 18:37:48 +0000 (19:37 +0100)
committerBrian Paul <brianp@vmware.com>
Mon, 7 Nov 2011 20:25:46 +0000 (13:25 -0700)
This series of patches is a splitted version of my previous one, as suggested by Brian.

Signed-off-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/softpipe/sp_state_derived.c
src/gallium/drivers/softpipe/sp_state_shader.c

index fd688089a3e6a2bd317a5ff8abd035538ef6c949..f89d23c9f26a4a7cb21c08d055ff791020be141f 100644 (file)
@@ -295,9 +295,12 @@ update_polygon_stipple_pattern(struct softpipe_context *softpipe)
    tex = util_pstipple_create_stipple_texture(&softpipe->pipe,
                                               softpipe->poly_stipple.stipple);
    pipe_resource_reference(&softpipe->pstipple.texture, tex);
+   pipe_resource_reference(&tex, NULL);
 
-   view = util_pstipple_create_sampler_view(&softpipe->pipe, tex);
+   view = util_pstipple_create_sampler_view(&softpipe->pipe,
+                                            softpipe->pstipple.texture);
    pipe_sampler_view_reference(&softpipe->pstipple.sampler_view, view);
+   pipe_sampler_view_reference(&view, NULL);
 }
 
 
index 3dd1f9eafaedd9330df5a026c12a8f5324c62da9..612dcb38eb41d3a7bbd81a7e5f0251bee9daa0af 100644 (file)
@@ -207,6 +207,7 @@ softpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
    draw_delete_fragment_shader(softpipe->draw, state->draw_shader);
 
    FREE((void *) state->shader.tokens);
+   FREE(state);
 }
 
 
@@ -335,6 +336,8 @@ softpipe_delete_gs_state(struct pipe_context *pipe, void *gs)
 
    draw_delete_geometry_shader(softpipe->draw,
                                (state) ? state->draw_data : 0);
+
+   FREE((void *) state->shader.tokens);
    FREE(state);
 }