From ec860ad1d4437f86809903e823bf45e01ec00b78 Mon Sep 17 00:00:00 2001 From: Justin Seyster Date: Fri, 11 Mar 2011 18:24:01 -0500 Subject: [PATCH] Adds comprehensive cleanup code. --- src/tracecut.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/tracecut.c b/src/tracecut.c index 73ee159..61a5ff8 100644 --- a/src/tracecut.c +++ b/src/tracecut.c @@ -553,6 +553,77 @@ remove_tracecut_from_list (struct tc_tracecut *tc) } } +static void +free_param_list (struct tc_tracecut *tc) +{ + struct tc_param *param = tc->param_list; + tc->param_list = NULL; + + while (param != NULL) + { + struct tc_param *next = param->next; + + free ((char *)param->name); + param->next = NULL; + free (param); + + param = next; + } +} + +static void +free_binding_list (struct tc_call_symbol *symbol) +{ + struct tc_call_binding *binding = symbol->binding_list; + symbol->binding_list = NULL; + + while (binding != NULL) + { + struct tc_call_binding *next = binding->next; + free (binding); + + binding = next; + } +} + +static void +free_symbol_list (struct tc_tracecut *tc) +{ + struct tc_call_symbol *symbol = tc->symbol_list; + tc->symbol_list = NULL; + + while (symbol != NULL) + { + struct tc_call_symbol *next = symbol->next; + + free ((char *)symbol->name); + free ((char *)symbol->func_name); + free_binding_list (symbol); + symbol->next = NULL; + free (symbol); + + symbol = next; + } +} + +static void +free_rule_list (struct tc_tracecut *tc) +{ + struct tc_rule *rule; + tc->rule_list = NULL; + + while (rule != NULL) + { + struct tc_rule *next = rule->next; + + free ((char *)rule->specification); + rule->next = NULL; + free (rule); + + rule = next; + } +} + /** * Free all the memory used by a tc_tracecut object. Every call to * tc_create_tracecut() should have a matching call to @@ -564,6 +635,10 @@ tc_free_tracecut (struct tc_tracecut *tc) { remove_tracecut_from_list (tc); + free_param_list (tc); + free_symbol_list (tc); + free_rule_list (tc); + free(tc); } -- 2.34.1