diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2004-08-14 14:28:11 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2004-08-14 14:28:11 +0000 |
commit | 21841f0ae5ca9b55ee23ecaa3513e91b6752aa16 (patch) | |
tree | e1b1fabb444d50c23a8461ab3839761756e1fb9b /src | |
parent | f226191d52b98eab83a1761f48c88688a4a27408 (diff) |
fix some memory leaks (bug #1002030)
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/context.c | 36 | ||||
-rw-r--r-- | src/mesa/main/depth.c | 10 | ||||
-rw-r--r-- | src/mesa/main/occlude.c | 54 | ||||
-rw-r--r-- | src/mesa/main/occlude.h | 7 | ||||
-rw-r--r-- | src/mesa/shader/program.c | 33 | ||||
-rw-r--r-- | src/mesa/shader/program.h | 3 |
6 files changed, 101 insertions, 42 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 67f797f96e..fd3174c0fa 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -894,8 +894,10 @@ alloc_shared_state( GLcontext *ctx ) if (ss->DefaultFragmentProgram) ctx->Driver.DeleteProgram(ctx, ss->DefaultFragmentProgram); #endif +#if FEATURE_ARB_vertex_buffer_object if (ss->BufferObjects) _mesa_DeleteHashTable(ss->BufferObjects); +#endif if (ss->Default1D) (*ctx->Driver.DeleteTexture)(ctx, ss->Default1D); @@ -941,6 +943,13 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) /* Free texture objects */ ASSERT(ctx->Driver.DeleteTexture); + /* the default textures */ + (*ctx->Driver.DeleteTexture)(ctx, ss->Default1D); + (*ctx->Driver.DeleteTexture)(ctx, ss->Default2D); + (*ctx->Driver.DeleteTexture)(ctx, ss->Default3D); + (*ctx->Driver.DeleteTexture)(ctx, ss->DefaultCubeMap); + (*ctx->Driver.DeleteTexture)(ctx, ss->DefaultRect); + /* all other textures */ while (1) { GLuint texName = _mesa_HashFirstEntry(ss->TexObjects); if (texName) { @@ -973,9 +982,16 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) } _mesa_DeleteHashTable(ss->Programs); #endif +#if FEATURE_ARB_vertex_program + _mesa_delete_program(ctx, ss->DefaultVertexProgram); +#endif +#if FEATURE_ARB_fragment_program + _mesa_delete_program(ctx, ss->DefaultFragmentProgram); +#endif +#if FEATURE_ARB_vertex_buffer_object _mesa_DeleteHashTable(ss->BufferObjects); - +#endif _glthread_DESTROY_MUTEX(ss->Mutex); FREE(ss); @@ -1530,19 +1546,11 @@ _mesa_free_context_data( GLcontext *ctx ) _mesa_free_matrix_data( ctx ); _mesa_free_viewport_data( ctx ); _mesa_free_colortables_data( 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)); - } + _mesa_free_program_data(ctx); + _mesa_free_occlude_data(ctx); + +#if FEATURE_ARB_vertex_buffer_object + _mesa_delete_buffer_object(ctx, ctx->Array.NullBufferObj); #endif /* Shared context state (display lists, textures, etc) */ diff --git a/src/mesa/main/depth.c b/src/mesa/main/depth.c index eb8c8b821b..d92423dcee 100644 --- a/src/mesa/main/depth.c +++ b/src/mesa/main/depth.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 6.1 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -177,10 +177,4 @@ void _mesa_init_depth( GLcontext * ctx ) ctx->DepthMaxF = (GLfloat) ctx->DepthMax; } ctx->MRD = 1.0; /* Minimum resolvable depth value, for polygon offset */ - -#if FEATURE_ARB_occlusion_query - ctx->Occlusion.QueryObjects = _mesa_NewHashTable(); -#endif - ctx->OcclusionResult = GL_FALSE; - ctx->OcclusionResultSaved = GL_FALSE; } diff --git a/src/mesa/main/occlude.c b/src/mesa/main/occlude.c index d329f11f09..bc61a475d6 100644 --- a/src/mesa/main/occlude.c +++ b/src/mesa/main/occlude.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 6.0.2 * * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * @@ -45,20 +45,6 @@ struct occlusion_query }; - -void -_mesa_init_occlude(GLcontext *ctx) -{ -#if FEATURE_ARB_occlusion_query - ctx->Occlusion.QueryObjects = _mesa_NewHashTable(); -#endif - - ctx->OcclusionResult = GL_FALSE; - ctx->OcclusionResultSaved = GL_FALSE; -} - - - /** * Allocate a new occlusion query object. * \param target - must be GL_SAMPLES_PASSED_ARB at this time @@ -327,3 +313,41 @@ _mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params) return; } } + + + +/** + * Allocate/init the context state related to occlusion query objects. + */ +void +_mesa_init_occlude(GLcontext *ctx) +{ +#if FEATURE_ARB_occlusion_query + ctx->Occlusion.QueryObjects = _mesa_NewHashTable(); +#endif + ctx->OcclusionResult = GL_FALSE; + ctx->OcclusionResultSaved = GL_FALSE; +} + + +/** + * Free the context state related to occlusion query objects. + */ +void +_mesa_free_occlude_data(GLcontext *ctx) +{ + while (1) { + GLuint query = _mesa_HashFirstEntry(ctx->Occlusion.QueryObjects); + if (query) { + struct occlusion_query *q = (struct occlusion_query *) + _mesa_HashLookup(ctx->Occlusion.QueryObjects, query); + ASSERT(q); + delete_query_object(q); + _mesa_HashRemove(ctx->Occlusion.QueryObjects, query); + } + else { + break; + } + } + _mesa_DeleteHashTable(ctx->Occlusion.QueryObjects); +} diff --git a/src/mesa/main/occlude.h b/src/mesa/main/occlude.h index 5696463aec..acf19101f1 100644 --- a/src/mesa/main/occlude.h +++ b/src/mesa/main/occlude.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 5.1 + * Version: 6.0.2 * - * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -30,6 +30,9 @@ extern void _mesa_init_occlude(GLcontext *ctx); +extern void +_mesa_free_occlude_data(GLcontext *ctx); + extern void GLAPIENTRY _mesa_GenQueriesARB(GLsizei n, GLuint *ids); diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 18bebd227a..daec9252ff 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 f71b46f1f7..48e0901501 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 * |