Mesa (glsl2): glsl_type: Add _mesa_glsl_release_types to release all type related storage
Ian Romanick
idr at kemper.freedesktop.org
Tue Jun 29 18:54:42 UTC 2010
Module: Mesa
Branch: glsl2
Commit: efc15f862b08a9f035c06a79bc43848cca740372
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=efc15f862b08a9f035c06a79bc43848cca740372
Author: Ian Romanick <ian.d.romanick at intel.com>
Date: Mon Jun 28 13:17:18 2010 -0700
glsl_type: Add _mesa_glsl_release_types to release all type related storage
---
src/glsl/glsl_types.cpp | 20 ++++++++++++++++++++
src/glsl/glsl_types.h | 14 ++++++++++++--
src/glsl/main.cpp | 1 +
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index 0d807fb..806b714 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -195,6 +195,26 @@ const glsl_type *glsl_type::get_base_type() const
}
+void
+_mesa_glsl_release_types(void)
+{
+ if (glsl_type::array_types != NULL) {
+ hash_table_dtor(glsl_type::array_types);
+ glsl_type::array_types = NULL;
+ }
+
+ if (glsl_type::record_types != NULL) {
+ hash_table_dtor(glsl_type::record_types);
+ glsl_type::record_types = NULL;
+ }
+
+ if (glsl_type::ctx != NULL) {
+ talloc_free(glsl_type::ctx);
+ glsl_type::ctx = NULL;
+ }
+}
+
+
ir_function *
glsl_type::generate_constructor(glsl_symbol_table *symtab) const
{
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index 1147d38..e869071 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -39,6 +39,9 @@ struct _mesa_glsl_parse_state;
extern "C" void
_mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state);
+extern "C" void
+_mesa_glsl_release_types(void);
+
#define GLSL_TYPE_UINT 0
#define GLSL_TYPE_INT 1
#define GLSL_TYPE_FLOAT 2
@@ -455,11 +458,18 @@ private:
bool);
static void generate_EXT_texture_array_types(class glsl_symbol_table *,
bool);
+ /*@}*/
+
/**
- * This function is a friend because it needs to call the various
- * generate_*_types functions and it has C linkage.
+ * \name Friend functions.
+ *
+ * These functions are friends because they must have C linkage and the
+ * need to call various private methods or access various private static
+ * data.
*/
+ /*@{*/
friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *);
+ friend void _mesa_glsl_release_types(void);
/*@}*/
};
diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
index 16b2cf8..342cf98 100644
--- a/src/glsl/main.cpp
+++ b/src/glsl/main.cpp
@@ -258,6 +258,7 @@ main(int argc, char **argv)
}
talloc_free(whole_program);
+ _mesa_glsl_release_types();
return status;
}
More information about the mesa-commit
mailing list