Mesa (asm-shader-rework-1): Add destructor for symbol_table
Ian Romanick
idr at kemper.freedesktop.org
Mon Jul 27 19:23:56 UTC 2009
Module: Mesa
Branch: asm-shader-rework-1
Commit: 946ea82bff530ac7aa8f5ebe56704fde62e14e86
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=946ea82bff530ac7aa8f5ebe56704fde62e14e86
Author: Ian Romanick <ian.d.romanick at intel.com>
Date: Mon Jul 27 12:19:14 2009 -0700
Add destructor for symbol_table
---
src/mesa/shader/symbol_table.c | 20 +++++++++++++++++---
src/mesa/shader/symbol_table.h | 1 +
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/mesa/shader/symbol_table.c b/src/mesa/shader/symbol_table.c
index b90c495..71ce128 100644
--- a/src/mesa/shader/symbol_table.c
+++ b/src/mesa/shader/symbol_table.c
@@ -325,10 +325,24 @@ _mesa_symbol_table_ctor(void)
{
struct _mesa_symbol_table *table = calloc(1, sizeof(*table));
- table->ht = hash_table_ctor(32, hash_table_string_hash,
- hash_table_string_compare);
+ if (table != NULL) {
+ table->ht = hash_table_ctor(32, hash_table_string_hash,
+ hash_table_string_compare);
- _mesa_symbol_table_push_scope(table);
+ _mesa_symbol_table_push_scope(table);
+ }
return table;
}
+
+
+void
+_mesa_symbol_table_dtor(struct _mesa_symbol_table *table)
+{
+ while (table->current_scope != NULL) {
+ _mesa_symbol_table_pop_scope(table);
+ }
+
+ hash_table_dtor(table->ht);
+ free(table);
+}
diff --git a/src/mesa/shader/symbol_table.h b/src/mesa/shader/symbol_table.h
index c543615..0c054ef 100644
--- a/src/mesa/shader/symbol_table.h
+++ b/src/mesa/shader/symbol_table.h
@@ -38,6 +38,7 @@ extern void *_mesa_symbol_table_find_symbol(
extern struct _mesa_symbol_table *_mesa_symbol_table_ctor(void);
+extern void _mesa_symbol_table_dtor(struct _mesa_symbol_table *);
extern struct _mesa_symbol_table_iterator *_mesa_symbol_table_iterator_ctor(
struct _mesa_symbol_table *table, int name_space, const char *name);
More information about the mesa-commit
mailing list