summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-03-26 09:23:44 -0600
committerBrian <[email protected]>2007-03-26 09:23:44 -0600
commitb9fbedd6012ac20fc14fda2cd18bdd86463d0527 (patch)
tree82ef8e5c891780c68f6a6c494208778598138455 /src
parentbb0393a0cdcabcb29ab7924cd4b3c4622fc2d787 (diff)
fix mem leak, add comments
Diffstat (limited to 'src')
-rw-r--r--src/mesa/shader/shader_api.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 002b42721df..1831d0fb2e7 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, GLuint name)
}
+/**
+ * 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 *ctx,
}
-
+/**
+ * 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, GLuint program, GLuint shader)
/* 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, GLuint program, GLuint shader)
newList[j++] = shProg->Shaders[i];
_mesa_free(shProg->Shaders);
- /* XXX refcounting! */
-
shProg->Shaders = newList;
return;
}