[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] grammar: free the association tracking graph
From: |
Theophile Ranquet |
Subject: |
[PATCH] grammar: free the association tracking graph |
Date: |
Fri, 1 Feb 2013 00:59:21 +0100 |
The graph introduced by Valentin wasn't free'd after use.
* src/symtab.c (cleanup_assoc): New, clear the array of linked lists with...
(cleanup_linkedlist): This, new.
(print_precedence_warnings): Call cleanup_assoc when done.
(print_assoc_warnings): Free used_assoc after use.
---
src/symtab.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/src/symtab.c b/src/symtab.c
index e48c11e..08ed6b5 100644
--- a/src/symtab.c
+++ b/src/symtab.c
@@ -1057,6 +1057,42 @@ register_precedence (graphid first, graphid snd)
}
+/*---------------------------------------.
+| Deep clear a linked / adjacency list). |
+`---------------------------------------*/
+
+static void
+cleanup_linkedlist (symgraphlink *node)
+{
+ if (node)
+ {
+ while (node->next)
+ {
+ symgraphlink *tmp = node->next;
+ free (node);
+ node = tmp;
+ }
+ free (node);
+ }
+}
+
+/*----------------------------------------------.
+| Clear and destroy association tracking table. |
+`----------------------------------------------*/
+
+static void
+cleanup_assoc (void)
+{
+ int i;
+ for (i = 0; i < nsyms; ++i)
+ {
+ cleanup_linkedlist (prec_nodes[i]->pred);
+ cleanup_linkedlist (prec_nodes[i]->succ);
+ free (prec_nodes[i]);
+ }
+ free (prec_nodes);
+}
+
/*--------------------------------------------------.
| Print a warning for unused precedence relations. |
`--------------------------------------------------*/
@@ -1078,6 +1114,7 @@ print_precedence_warnings (void)
complain (&s->location, Wother,
_("useless precedence for %s"), s->tag);
}
+ cleanup_assoc ();
}
/*---------------------------------------.
@@ -1136,4 +1173,5 @@ print_assoc_warnings (void)
complain (&s->location, Wother,
_("useless associativity for %s"), s->tag);
}
+ free (used_assoc);
}
--
1.8.1.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] grammar: free the association tracking graph,
Theophile Ranquet <=