[Mesa-dev] [PATCH] Fix memory leaks and some bad indentation

Morgan Armand morgan.devel at gmail.com
Sun Nov 6 14:07:01 PST 2011


---
 src/gallium/drivers/softpipe/sp_state_derived.c |    5 ++++-
 src/gallium/drivers/softpipe/sp_state_shader.c  |    3 +++
 src/mesa/state_tracker/st_atom_texture.c        |   11 +++++------
 src/mesa/state_tracker/st_cb_drawpixels.c       |   10 +++++-----
 4 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c
index fd68808..f89d23c 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -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);
 }


diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c b/src/gallium/drivers/softpipe/sp_state_shader.c
index 3dd1f9e..612dcb3 100644
--- a/src/gallium/drivers/softpipe/sp_state_shader.c
+++ b/src/gallium/drivers/softpipe/sp_state_shader.c
@@ -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);
 }

diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 3115a25..008e9bd 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -267,14 +267,13 @@ update_vertex_textures(struct st_context *st)
          GLboolean retval;
          GLuint texUnit;

-	 texUnit = vprog->Base.SamplerUnits[su];
+         texUnit = vprog->Base.SamplerUnits[su];

-	 retval = update_single_texture(st, &sampler_view, texUnit);
-	 if (retval == GL_FALSE)
-	    continue;
-
-	 st->state.num_vertex_textures = su + 1;
+         retval = update_single_texture(st, &sampler_view, texUnit);
+         if (retval == GL_FALSE)
+            continue;

+         st->state.num_vertex_textures = su + 1;
       }
       pipe_sampler_view_reference(&st->state.sampler_vertex_views[su], sampler_view);
    }
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 1c44d0d..5714d34 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1135,10 +1135,10 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
                   assert(0);
                }

-	       sv[1] = st_create_texture_sampler_view_format(st->pipe, pt,
+               sv[1] = st_create_texture_sampler_view_format(st->pipe, pt,
                                                              stencil_format);
-	       num_sampler_view++;
-	    }
+               num_sampler_view++;
+            }

             draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2],
                                width, height,
@@ -1638,9 +1638,9 @@ st_destroy_drawpix(struct st_context *st)

    st_reference_fragprog(st, &st->pixel_xfer.combined_prog, NULL);
    if (st->drawpix.vert_shaders[0])
-      ureg_free_tokens(st->drawpix.vert_shaders[0]);
+      cso_delete_vertex_shader(st->cso_context, st->drawpix.vert_shaders[0]);
    if (st->drawpix.vert_shaders[1])
-      ureg_free_tokens(st->drawpix.vert_shaders[1]);
+      cso_delete_vertex_shader(st->cso_context, st->drawpix.vert_shaders[1]);
 }

 #endif /* FEATURE_drawpix */
-- 
1.7.7.1.msysgit.0



More information about the mesa-dev mailing list