Mesa (master): ARB prog parser: Don't leak symbol table header structures

Brian Paul brianp at kemper.freedesktop.org
Wed Oct 28 17:33:47 UTC 2009


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

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Tue Oct 27 11:44:56 2009 -0700

ARB prog parser: Don't leak symbol table header structures

---

 src/mesa/shader/symbol_table.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/mesa/shader/symbol_table.c b/src/mesa/shader/symbol_table.c
index 7a9aa7b..42601a7 100644
--- a/src/mesa/shader/symbol_table.c
+++ b/src/mesa/shader/symbol_table.c
@@ -73,6 +73,9 @@ struct symbol {
 /**
  */
 struct symbol_header {
+    /** Linkage in list of all headers in a given symbol table. */
+    struct symbol_header *next;
+
     /** Symbol name. */
     const char *name;
 
@@ -102,6 +105,9 @@ struct _mesa_symbol_table {
 
     /** Top of scope stack. */
     struct scope_level *current_scope;
+
+    /** List of all symbol headers in the table. */
+    struct symbol_header *hdr;
 };
 
 
@@ -301,6 +307,8 @@ _mesa_symbol_table_add_symbol(struct _mesa_symbol_table *table,
         hdr->name = name;
 
         hash_table_insert(table->ht, hdr, name);
+	hdr->next = table->hdr;
+	table->hdr = hdr;
     }
 
     check_symbol_table(table);
@@ -341,10 +349,18 @@ _mesa_symbol_table_ctor(void)
 void
 _mesa_symbol_table_dtor(struct _mesa_symbol_table *table)
 {
+   struct symbol_header *hdr;
+   struct symbol_header *next;
+
    while (table->current_scope != NULL) {
       _mesa_symbol_table_pop_scope(table);
    }
 
+   for (hdr = table->hdr; hdr != NULL; hdr = next) {
+       next = hdr->next;
+       _mesa_free(hdr);
+   }
+
    hash_table_dtor(table->ht);
    free(table);
 }




More information about the mesa-commit mailing list