File recode-3.6-memleak.patch of Package recode

2000-07-26  Andreas Schwab  <schwab@suse.de>

	* names.c (alias_free): New function.
	(prepare_for_aliases): Pass it to hash_initialize.
	* outer.c (recode_delete_outer): Free elements of
	argmatch_charset_array and argmatch_surface_array.

Index: recode-3.6/src/names.c
===================================================================
--- recode-3.6.orig/src/names.c
+++ recode-3.6/src/names.c
@@ -101,6 +101,20 @@ alias_comparator (const void *void_first
   return strcmp (first->name, second->name) == 0;
 }
 
+static void
+alias_free (void *void_alias)
+{
+  RECODE_ALIAS alias = void_alias;
+  struct recode_surface_list *list, *next;
+
+  for (list = alias->implied_surfaces; list != NULL; list = next)
+    {
+      next = list->next;
+      free (list);
+    }
+  free (alias);
+}
+
 bool
 prepare_for_aliases (RECODE_OUTER outer)
 {
@@ -108,7 +122,7 @@ prepare_for_aliases (RECODE_OUTER outer)
   outer->number_of_symbols = 0;
 
   outer->alias_table
-    = hash_initialize (800, NULL, alias_hasher, alias_comparator, free);
+    = hash_initialize (800, NULL, alias_hasher, alias_comparator, alias_free);
   if (!outer->alias_table)
     return false;
 
Index: recode-3.6/src/outer.c
===================================================================
--- recode-3.6.orig/src/outer.c
+++ recode-3.6/src/outer.c
@@ -617,7 +617,15 @@ recode_delete_outer (RECODE_OUTER outer)
   if (outer->alias_table)
     hash_free (outer->alias_table);
   if (outer->argmatch_charset_array)
-    free (outer->argmatch_charset_array);
+    {
+      char **cursor;
+
+      for (cursor = outer->argmatch_charset_array; *cursor; cursor++)
+	free (*cursor);
+      for (cursor = outer->argmatch_surface_array; *cursor; cursor++)
+	free (*cursor);
+      free (outer->argmatch_charset_array);
+    }
   if (outer->one_to_same)
     free ((void *) outer->one_to_same);
   free (outer);