}
+/**
+ * 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)
}
-
+/**
+ * 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);
}
/* 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 **)
newList[j++] = shProg->Shaders[i];
_mesa_free(shProg->Shaders);
- /* XXX refcounting! */
-
shProg->Shaders = newList;
return;
}