From 86af3872a910e314d20ef911fad1819ad90c1291 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Tue, 14 Feb 2006 15:42:17 +0000 Subject: Some memory leak cleanups (found with valgrind). --- variable.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index 54ac046..0ea71cd 100644 --- a/variable.c +++ b/variable.c @@ -539,14 +539,6 @@ initialize_file_variables (struct file *file, int reading) /* Pop the top set off the current variable set list, and free all its storage. */ -static void -free_variable_name_and_value (const void *item) -{ - struct variable *v = (struct variable *) item; - free (v->name); - free (v->value); -} - struct variable_set_list * create_new_variable_set (void) { @@ -565,6 +557,23 @@ create_new_variable_set (void) return setlist; } +static void +free_variable_name_and_value (const void *item) +{ + struct variable *v = (struct variable *) item; + free (v->name); + free (v->value); +} + +void +free_variable_set (struct variable_set_list *list) +{ + hash_map (&list->set->table, free_variable_name_and_value); + hash_free (&list->set->table, 1); + free ((char *) list->set); + free ((char *) list); +} + /* Create a new variable set and push it on the current setlist. If we're pushing a global scope (that is, the current scope is the global scope) then we need to "push" it the other way: file variable sets point -- cgit v1.2.3