Adds comprehensive cleanup code.
authorJustin Seyster <jseyster@cs.sunysb.edu>
Fri, 11 Mar 2011 23:24:01 +0000 (18:24 -0500)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Fri, 11 Mar 2011 23:24:01 +0000 (18:24 -0500)
src/tracecut.c

index 73ee1598a71e229c605921e16f6f502e6da2fa2b..61a5ff8cdd1f8fe18dbe327a9f46a6370aa37b5b 100644 (file)
@@ -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);
 }