Mesa (master): glsl: Rely on talloc_autofree_context() instead of trying to free on our own.

Eric Anholt anholt at kemper.freedesktop.org
Tue Aug 24 00:26:24 UTC 2010


Module: Mesa
Branch: master
Commit: 8dd619ba6825e673a357336b69c96accaa96a7ef
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8dd619ba6825e673a357336b69c96accaa96a7ef

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Aug 23 17:16:25 2010 -0700

glsl: Rely on talloc_autofree_context() instead of trying to free on our own.

Because the static types talloc their names at dlopen time,
talloc_freeing the types at DRI driver screen teardown means that if
the screen gets brought back up again, the names will point at freed
memory.  talloc_autofree_context() exists to do just what we want
here: Free memory referenced across the program's lifetime so that we
avoid noise in memory leak checkers.

Fixes: bug #29722 (assertion failure in unigine).

---

 src/glsl/glsl_types.cpp |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index 518abc9..c488f5c 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -41,7 +41,7 @@ void
 glsl_type::init_talloc_type_ctx(void)
 {
    if (glsl_type::mem_ctx == NULL) {
-      glsl_type::mem_ctx = talloc_init("glsl_type");
+      glsl_type::mem_ctx = talloc_autofree_context();
       assert(glsl_type::mem_ctx != NULL);
    }
 }
@@ -230,11 +230,6 @@ _mesa_glsl_release_types(void)
       hash_table_dtor(glsl_type::record_types);
       glsl_type::record_types = NULL;
    }
-
-   if (glsl_type::mem_ctx != NULL) {
-      talloc_free(glsl_type::mem_ctx);
-      glsl_type::mem_ctx = NULL;
-   }
 }
 
 




More information about the mesa-commit mailing list