about summary refs log tree commit diff
path: root/locale
diff options
context:
space:
mode:
Diffstat (limited to 'locale')
-rw-r--r--locale/C-collate.c2
-rw-r--r--locale/C-ctype.c2
-rw-r--r--locale/C-messages.c2
-rw-r--r--locale/C-monetary.c2
-rw-r--r--locale/C-numeric.c2
-rw-r--r--locale/C-time.c2
-rw-r--r--locale/findlocale.c27
-rw-r--r--locale/loadlocale.c11
-rw-r--r--locale/localeinfo.h6
-rw-r--r--locale/programs/localedef.c2
10 files changed, 48 insertions, 10 deletions
diff --git a/locale/C-collate.c b/locale/C-collate.c
index 5c049e1f59..ba85002d5c 100644
--- a/locale/C-collate.c
+++ b/locale/C-collate.c
@@ -147,7 +147,7 @@ const struct locale_data _nl_C_LC_COLLATE =
 {
   _nl_C_name,
   NULL, 0, 0, /* no file mapped */
-  MAX_USAGE_COUNT,
+  UNDELETABLE,
   21,
   {
     { word: 0 },
diff --git a/locale/C-ctype.c b/locale/C-ctype.c
index 6a1c3fc7be..851b95fd98 100644
--- a/locale/C-ctype.c
+++ b/locale/C-ctype.c
@@ -342,7 +342,7 @@ const struct locale_data _nl_C_LC_CTYPE =
 {
   _nl_C_name,
   NULL, 0, 0, /* no file mapped */
-  MAX_USAGE_COUNT,
+  UNDELETABLE,
   15,
   {
     { string: _nl_C_LC_CTYPE_class },
diff --git a/locale/C-messages.c b/locale/C-messages.c
index 70eeb8cc80..0363020476 100644
--- a/locale/C-messages.c
+++ b/locale/C-messages.c
@@ -28,7 +28,7 @@ const struct locale_data _nl_C_LC_MESSAGES =
 {
   _nl_C_name,
   NULL, 0, 0, /* no file mapped */
-  MAX_USAGE_COUNT,
+  UNDELETABLE,
   4,
   {
     { string: "^[yY]" },
diff --git a/locale/C-monetary.c b/locale/C-monetary.c
index 8dd361a2e0..0133319740 100644
--- a/locale/C-monetary.c
+++ b/locale/C-monetary.c
@@ -31,7 +31,7 @@ const struct locale_data _nl_C_LC_MONETARY =
 {
   _nl_C_name,
   NULL, 0, 0, /* no file mapped */
-  MAX_USAGE_COUNT,
+  UNDELETABLE,
   15,
   {
     { string: "" },
diff --git a/locale/C-numeric.c b/locale/C-numeric.c
index a456214213..d42c5266be 100644
--- a/locale/C-numeric.c
+++ b/locale/C-numeric.c
@@ -31,7 +31,7 @@ const struct locale_data _nl_C_LC_NUMERIC =
 {
   _nl_C_name,
   NULL, 0, 0, /* no file mapped */
-  MAX_USAGE_COUNT,
+  UNDELETABLE,
   3,
   {
     { string: "." },
diff --git a/locale/C-time.c b/locale/C-time.c
index 095d097e2b..673d9bd478 100644
--- a/locale/C-time.c
+++ b/locale/C-time.c
@@ -26,7 +26,7 @@ const struct locale_data _nl_C_LC_TIME =
 {
   _nl_C_name,
   NULL, 0, 0, /* no file mapped */
-  MAX_USAGE_COUNT,
+  UNDELETABLE,
   54,
   {
     { string: "Sun" },
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);
diff --git a/locale/loadlocale.c b/locale/loadlocale.c
index 15570c36d1..3ac161eb3a 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -221,3 +221,14 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
   __close (fd);
   file->data = newdata;
 }
+
+void
+_nl_unload_locale (struct locale_data *locale)
+{
+  if (locale->mmaped)
+    __munmap ((caddr_t) locale->filedata, locale->filesize);
+  else
+    free ((void *) locale->filedata);
+
+  free (locale);
+}
diff --git a/locale/localeinfo.h b/locale/localeinfo.h
index 29731fa4c6..f50565c54a 100644
--- a/locale/localeinfo.h
+++ b/locale/localeinfo.h
@@ -38,7 +38,8 @@
 
 /* We use a special value for the usage counter in `locale_data' to
    signal that this data must never be removed anymore.  */
-#define MAX_USAGE_COUNT UINT_MAX
+#define MAX_USAGE_COUNT (UINT_MAX - 1)
+#define UNDELETABLE	UINT_MAX
 
 /* Structure describing locale data in core for a category.  */
 struct locale_data
@@ -135,6 +136,9 @@ extern struct locale_data *_nl_find_locale (const char *locale_path,
 /* Try to load the file described by FILE.  */
 extern void _nl_load_locale (struct loaded_l10nfile *file, int category);
 
+/* Free all resource.  */
+extern void _nl_unload_locale (struct locale_data *locale);
+
 /* Free the locale and give back all memory if the usage count is one.  */
 extern void _nl_remove_locale (int locale, struct locale_data *data);
 
diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c
index 6290274a72..c511d4246c 100644
--- a/locale/programs/localedef.c
+++ b/locale/programs/localedef.c
@@ -108,7 +108,7 @@ static const struct argp_option options[] =
   { "posix", OPT_POSIX, NULL, 0, N_("Be strictly POSIX conform") },
   { "quiet", OPT_QUIET, NULL, 0,
     N_("Suppress warnings and information messages") },
-  { "verbose", 'V', NULL, 0, N_("Print more messages") },
+  { "verbose", 'v', NULL, 0, N_("Print more messages") },
   { NULL, 0, NULL, 0, NULL }
 };