* src/named-ref.c: Add a pointer check (named_ref_free).
* src/scan-code.l: New function (variant_table_free). Called in
code_scanner_free.
* src/symlist.c: Call to named_ref_free (symbol_list_free).
+2009-07-24 Alex Rozenman <rozenmam@gmail.com>
+
+ Fix some memory leaks.
+ * src/named-ref.c: Add a pointer check (named_ref_free).
+ * src/scan-code.l: New function (variant_table_free). Called in
+ code_scanner_free.
+ * src/symlist.c: Call to named_ref_free (symbol_list_free).
+
2009-07-24 Joel E. Denny <jdenny@ces.clemson.edu>
Warn about character literals not of length one.
void
named_ref_free (named_ref *r)
{
- free (r);
+ if (r)
+ free (r);
}
return &variant_table[variant_count - 1];
}
+static void
+variant_table_free ()
+{
+ if (variant_table)
+ free (variant_table);
+ variant_table = 0;
+ variant_table_size = variant_count = 0;
+}
+
static char *
find_prefix_end (const char *prefix, char *begin, char *end)
{
code_scanner_free (void)
{
obstack_free (&obstack_for_string, 0);
+ variant_table_free ();
+
/* Reclaim Flex's buffers. */
yylex_destroy ();
}
void
symbol_list_free (symbol_list *list)
{
- LIST_FREE (symbol_list, list);
+ symbol_list *node, *next;
+ for (node = list; node; node = next)
+ {
+ next = node->next;
+ if (node->named_ref)
+ named_ref_free (node->named_ref);
+ free (node);
+ }
}