Mesa (master): draw: Fix memory leak in gs code

Jakob Bornecrantz wallbraker at kemper.freedesktop.org
Sat Jan 16 12:05:03 UTC 2010


Module: Mesa
Branch: master
Commit: a5c03bd6f16517bf35c273741080492d70d64c29
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a5c03bd6f16517bf35c273741080492d70d64c29

Author: Jakob Bornecrantz <jakob at vmware.com>
Date:   Sat Jan 16 09:30:28 2010 +0000

draw: Fix memory leak in gs code

---

 src/gallium/auxiliary/draw/draw_context.c |    1 +
 src/gallium/auxiliary/draw/draw_gs.c      |    9 +++++++++
 src/gallium/auxiliary/draw/draw_private.h |    1 +
 3 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 667aa46..e90dfc5 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -95,6 +95,7 @@ void draw_destroy( struct draw_context *draw )
    draw_pipeline_destroy( draw );
    draw_pt_destroy( draw );
    draw_vs_destroy( draw );
+   draw_gs_destroy( draw );
 
    FREE( draw );
 }
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
index 5db2e75..daf8d07 100644
--- a/src/gallium/auxiliary/draw/draw_gs.c
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -59,6 +59,15 @@ draw_gs_init( struct draw_context *draw )
    return TRUE;
 }
 
+void draw_gs_destroy( struct draw_context *draw )
+{
+   if (!draw->gs.machine)
+      return;
+
+   align_free(draw->gs.machine->Primitives);
+
+   tgsi_exec_machine_destroy(draw->gs.machine);
+}
 
 void draw_gs_set_constants( struct draw_context *draw,
                             const float (*constants)[4],
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index d5e1c0c..ef49e57 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -269,6 +269,7 @@ boolean draw_gs_init( struct draw_context *draw );
 void draw_gs_set_constants( struct draw_context *,
                             const float (*constants)[4],
                             unsigned size );
+void draw_gs_destroy( struct draw_context *draw );
 
 /*******************************************************************************
  * Common shading code:




More information about the mesa-commit mailing list