From efc15f862b08a9f035c06a79bc43848cca740372 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 28 Jun 2010 13:17:18 -0700 Subject: 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(-) (limited to 'src/glsl') diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 0d807fbc3d..806b71495d 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 1147d38ca6..e869071cab 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 16b2cf84c5..342cf98840 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; } -- cgit v1.2.3