summary refs log tree commit diff
path: root/locale/findlocale.c
diff options
context:
space:
mode:
Diffstat (limited to 'locale/findlocale.c')
-rw-r--r--locale/findlocale.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/locale/findlocale.c b/locale/findlocale.c
index c027968530..b651dbaaad 100644
--- a/locale/findlocale.c
+++ b/locale/findlocale.c
@@ -176,7 +176,7 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
 
   /* Increment the usage count.  */
   if (((struct locale_data *) locale_file->data)->usage_count
-      != MAX_USAGE_COUNT)
+      < MAX_USAGE_COUNT)
     ++((struct locale_data *) locale_file->data)->usage_count;
 
   return (struct locale_data *) locale_file->data;
@@ -213,7 +213,7 @@ _nl_remove_locale (int locale, struct locale_data *data)
 	     permanent.  */
 	  if (__munmap ((caddr_t) data->filedata, data->filesize) != 0)
 	    {
-	      data->usage_count = MAX_USAGE_COUNT;
+	      data->usage_count = UNDELETABLE;
 	      return;
 	    }
 	}
@@ -225,3 +225,26 @@ _nl_remove_locale (int locale, struct locale_data *data)
       free (data);
     }
 }
+
+static void __attribute__ ((unused))
+free_mem (void)
+{
+  int locale;
+
+  for (locale = 0; locale < LC_ALL; ++locale)
+    {
+      struct loaded_l10nfile *runp = locale_file_list[locale];
+
+      while (runp != NULL)
+	{
+	  struct loaded_l10nfile *here = runp;
+	  struct locale_data *data = (struct locale_data *) runp->data;
+
+	  if (data != NULL && data->usage_count != UNDELETABLE)
+	    _nl_unload_locale (data);
+	  runp = runp->next;
+	  free (here);
+	}
+    }
+}
+text_set_element (__libc_subfreeres, free_mem);