fix some memory leaks (bug #1002030)

This commit is contained in:
Brian Paul
2004-08-14 14:28:11 +00:00
parent f226191d52
commit 21841f0ae5
6 changed files with 101 additions and 42 deletions

View File

@@ -47,7 +47,7 @@
/**
* Init context's program state
* Init context's vertex/fragment program state
*/
void
_mesa_init_program(GLcontext *ctx)
@@ -79,6 +79,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);
}