From 6614d40162a58ad4ada331cbfa52e5a3252ffd55 Mon Sep 17 00:00:00 2001 From: felipebart Date: Tue, 18 Dec 2007 15:01:34 +0000 Subject: [PATCH] =?utf8?q?Concertando=20as=20fun=C3=A7=C3=B5es=20lookup=20?= =?utf8?q?e=20destroy?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://toypasc.googlecode.com/svn/trunk@12 cbd757d2-8441-0410-81db-47b75ec2d254 --- symbol_table.c | 12 +++++++----- symbol_table.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/symbol_table.c b/symbol_table.c index ae29fd7..1c35832 100755 --- a/symbol_table.c +++ b/symbol_table.c @@ -33,6 +33,7 @@ symbol_insert(Symbol * table, char const * name, int type) symbol = symbol_new(name); symbol->type = type; + symbol->next = table; return symbol; } @@ -60,16 +61,17 @@ symbol_lookup(Symbol * table, char const * name) } void -symbol_table_destroy(Symbol *table) +symbol_table_destroy(Symbol **table) { Symbol *first; - Symbol *second; - first = table; + Symbol *to_kill; + first = *table; + *table = NULL; while(first != NULL){ - second = first; + to_kill = first; first = first->next; - free(second); + free(to_kill); } free(first); diff --git a/symbol_table.h b/symbol_table.h index f7cc7db..a5287c9 100755 --- a/symbol_table.h +++ b/symbol_table.h @@ -16,7 +16,7 @@ typedef struct _symbol { Symbol *symbol_insert(Symbol *table, char const *name, int type); Symbol *symbol_lookup(Symbol *table, char const *name); -void symbol_table_destroy(Symbol *table); +void symbol_table_destroy(Symbol **table); void symbol_print(Symbol *symbol); void symbol_table_dump(Symbol *table); -- 2.11.4.GIT