[Mesa-dev] [PATCH 14/17] mesa: Free new structures stored in shader/program at exit

Vincent Lejeune vljn at ovi.com
Sun Dec 25 10:20:09 PST 2011


---
 src/mesa/main/shaderobj.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 454007f..8a2e159 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -110,6 +110,7 @@ _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
    if (shader) {
       shader->Type = type;
       shader->Name = name;
+      shader->UBOCount = 0;
       _mesa_init_shader(ctx, shader);
    }
    return shader;
@@ -296,7 +297,6 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
    shProg->InfoLog = ralloc_strdup(shProg, "");
 }
 
-
 /**
  * Free all the data that hangs off a shader program object, but not the
  * object itself.
@@ -305,7 +305,7 @@ void
 _mesa_free_shader_program_data(struct gl_context *ctx,
                                struct gl_shader_program *shProg)
 {
-   GLuint i;
+   GLuint i,j;
    gl_shader_type sh;
 
    assert(shProg->Type == GL_SHADER_PROGRAM_MESA);
@@ -348,6 +348,25 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
 	 shProg->_LinkedShaders[sh] = NULL;
       }
    }
+
+   for (i = 0; i < shProg->IndexedVariableCount; i++) {
+      free(shProg->IndexedUBOVariables[i].Name);
+   }
+   if(shProg->IndexedVariableCount)
+      free(shProg->IndexedUBOVariables);
+   shProg->IndexedVariableCount = 0;
+
+   for (i = 0; i < shProg->UBOCount; i++) {
+      free(shProg->UniformBufferObject[i].Name);
+      for (j = 0; j < shProg->UniformBufferObject[i].NumberOfVariables; j++) {
+         free(shProg->UniformBufferObject[i].Variables[j].Name);
+         ralloc_free(shProg->UniformBufferObject[i].Variables[j].Storage);
+      }
+   }
+
+   if (shProg->UBOCount)
+      free(shProg->UniformBufferObject);
+   shProg->UBOCount = 0;
 }
 
 
-- 
1.7.7



More information about the mesa-dev mailing list