summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2009-03-20 16:23:50 +0100
committerPatrick McHardy <kaber@trash.net>2009-03-20 16:23:50 +0100
commit7feffa0ed35e4125f272edded092b890234a794b (patch)
treecc544f616aad5e44cb9b9486e69c456a0ea59312 /src
parent0e217b46129e6f39fe38354c6682d839f4c8ae34 (diff)
Release scopes during cleanup
Properly release the user-defined symbols. Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'src')
-rw-r--r--src/main.c1
-rw-r--r--src/rule.c14
2 files changed, 15 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index f7686ae3..00f594f6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -195,6 +195,7 @@ int main(int argc, char * const *argv)
}
out:
scanner_destroy(scanner);
+ scope_release(&state.top_scope);
erec_print_list(stdout, &msgs);
xfree(buf);
diff --git a/src/rule.c b/src/rule.c
index 8efbd887..6f322b8b 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -75,6 +75,18 @@ struct scope *scope_init(struct scope *scope, const struct scope *parent)
return scope;
}
+void scope_release(const struct scope *scope)
+{
+ struct symbol *sym, *next;
+
+ list_for_each_entry_safe(sym, next, &scope->symbols, list) {
+ list_del(&sym->list);
+ xfree(sym->identifier);
+ expr_free(sym->expr);
+ xfree(sym);
+ }
+}
+
void symbol_bind(struct scope *scope, const char *identifier, struct expr *expr)
{
struct symbol *sym;
@@ -118,6 +130,7 @@ void chain_free(struct chain *chain)
list_for_each_entry_safe(rule, next, &chain->rules, list)
rule_free(rule);
handle_free(&chain->handle);
+ scope_release(&chain->scope);
xfree(chain);
}
@@ -165,6 +178,7 @@ void table_free(struct table *table)
list_for_each_entry_safe(chain, next, &table->chains, list)
chain_free(chain);
handle_free(&table->handle);
+ scope_release(&table->scope);
xfree(table);
}