aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2004-08-14 14:28:11 +0000
committerBrian Paul <[email protected]>2004-08-14 14:28:11 +0000
commit21841f0ae5ca9b55ee23ecaa3513e91b6752aa16 (patch)
treee1b1fabb444d50c23a8461ab3839761756e1fb9b /src/mesa/shader
parentf226191d52b98eab83a1761f48c88688a4a27408 (diff)
fix some memory leaks (bug #1002030)
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/program.c33
-rw-r--r--src/mesa/shader/program.h3
2 files changed, 33 insertions, 3 deletions
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index 18bebd227ab..daec9252fff 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -47,7 +47,7 @@
/**
- * Init context's program state
+ * Init context's vertex/fragment program state
*/
void
_mesa_init_program(GLcontext *ctx)
@@ -80,6 +80,32 @@ _mesa_init_program(GLcontext *ctx)
/**
+ * Free a context's vertex/fragment program state
+ */
+void
+_mesa_free_program_data(GLcontext *ctx)
+{
+#if FEATURE_NV_vertex_program
+ if (ctx->VertexProgram.Current) {
+ ctx->VertexProgram.Current->Base.RefCount--;
+ if (ctx->VertexProgram.Current->Base.RefCount <= 0)
+ ctx->Driver.DeleteProgram(ctx, &(ctx->VertexProgram.Current->Base));
+ }
+#endif
+#if FEATURE_NV_fragment_program
+ if (ctx->FragmentProgram.Current) {
+ ctx->FragmentProgram.Current->Base.RefCount--;
+ if (ctx->FragmentProgram.Current->Base.RefCount <= 0)
+ ctx->Driver.DeleteProgram(ctx, &(ctx->FragmentProgram.Current->Base));
+ }
+#endif
+ _mesa_free((void *) ctx->Program.ErrorString);
+}
+
+
+
+
+/**
* Set the vertex/fragment program error state (position and error string).
* This is generally called from within the parsers.
*/
@@ -222,15 +248,16 @@ _mesa_delete_program(GLcontext *ctx, struct program *prog)
struct vertex_program *vprog = (struct vertex_program *) prog;
if (vprog->Instructions)
_mesa_free(vprog->Instructions);
+ if (vprog->Parameters)
+ _mesa_free_parameter_list(vprog->Parameters);
}
else if (prog->Target == GL_FRAGMENT_PROGRAM_NV ||
prog->Target == GL_FRAGMENT_PROGRAM_ARB) {
struct fragment_program *fprog = (struct fragment_program *) prog;
if (fprog->Instructions)
_mesa_free(fprog->Instructions);
- if (fprog->Parameters) {
+ if (fprog->Parameters)
_mesa_free_parameter_list(fprog->Parameters);
- }
}
_mesa_free(prog);
}
diff --git a/src/mesa/shader/program.h b/src/mesa/shader/program.h
index f71b46f1f70..48e09015010 100644
--- a/src/mesa/shader/program.h
+++ b/src/mesa/shader/program.h
@@ -52,6 +52,9 @@ extern void
_mesa_init_program(GLcontext *ctx);
extern void
+_mesa_free_program_data(GLcontext *ctx);
+
+extern void
_mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string);
extern const GLubyte *