mesa: Branch 'glsl-compiler-1' - 2 commits

Brian Paul brianp at kemper.freedesktop.org
Mon Mar 26 15:26:45 UTC 2007


 src/mesa/shader/shader_api.c     |   18 +++++++++++++++---
 src/mesa/shader/slang/slang_ir.c |    2 ++
 2 files changed, 17 insertions(+), 3 deletions(-)

New commits:
diff-tree e71c34aaa173ca451fa02e526ead77758f7eeb74 (from b9fbedd6012ac20fc14fda2cd18bdd86463d0527)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Mar 26 09:24:30 2007 -0600

    disable free() until other issues can be fixed...

diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c
index 59aac73..14a7b69 100644
--- a/src/mesa/shader/slang/slang_ir.c
+++ b/src/mesa/shader/slang/slang_ir.c
@@ -144,7 +144,9 @@ _slang_free_ir(slang_ir_node *n)
    if (n->Store) {
       n->Store->RefCount--;
       if (n->Store->RefCount == 0) {
+#if 0
          free(n->Store);
+#endif
          n->Store = NULL;
       }
    }
diff-tree b9fbedd6012ac20fc14fda2cd18bdd86463d0527 (from bb0393a0cdcabcb29ab7924cd4b3c4622fc2d787)
Author: Brian <brian at yutani.localnet.net>
Date:   Mon Mar 26 09:23:44 2007 -0600

    fix mem leak, add comments

diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 002b427..1831d0f 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -67,6 +67,10 @@ _mesa_new_shader_program(GLcontext *ctx,
 }
 
 
+/**
+ * Free the data that hangs off a shader program object, but not the object
+ * itself.
+ */
 void
 _mesa_free_shader_program_data(GLcontext *ctx,
                                struct gl_shader_program *shProg)
@@ -104,11 +108,17 @@ _mesa_free_shader_program_data(GLcontext
 }
 
 
-
+/**
+ * Free/delete a shader program object.
+ */
 void
 _mesa_free_shader_program(GLcontext *ctx, struct gl_shader_program *shProg)
 {
    _mesa_free_shader_program_data(ctx, shProg);
+   if (shProg->Shaders) {
+      _mesa_free(shProg->Shaders);
+      shProg->Shaders = NULL;
+   }
    _mesa_free(shProg);
 }
 
@@ -431,6 +441,10 @@ _mesa_detach_shader(GLcontext *ctx, GLui
          /* found it */
 
          shProg->Shaders[i]->RefCount--;
+         if (shProg->Shaders[i]->RefCount == 0) {
+            /* delete now */
+            _mesa_free_shader(ctx, shProg->Shaders[i]);
+         }
 
          /* alloc new, smaller array */
          newList = (struct gl_shader **)
@@ -446,8 +460,6 @@ _mesa_detach_shader(GLcontext *ctx, GLui
             newList[j++] = shProg->Shaders[i];
          _mesa_free(shProg->Shaders);
 
-         /* XXX refcounting! */
-
          shProg->Shaders = newList;
          return;
       }



More information about the mesa-commit mailing list