about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--intl/finddomain.c5
-rw-r--r--locale/findlocale.c18
-rw-r--r--locale/setlocale.c24
4 files changed, 39 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 91e27dadb2..31df8ed340 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 1999-01-28  Ulrich Drepper  <drepper@cygnus.com>
 
+	* intl/finddomain.c (free_mem): Also free filename.
+	* locale/findlocale.c (free_mem): Likewise.
+	(_nl_find_locale): Duplicate loc_name with strdupa not strdup.
+	* locale/setlocale.c (free_mem): New function.  Free current locale
+	data and set current locale to "C".
+
 	* libio/genops.c (_IO_un_link): Move #ifdef introduced in last
 	change in right place.
 
diff --git a/intl/finddomain.c b/intl/finddomain.c
index 0b697ef053..7734fbf24f 100644
--- a/intl/finddomain.c
+++ b/intl/finddomain.c
@@ -1,6 +1,6 @@
 /* Handle list of needed message catalogs
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
-   Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
+   Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Written by Ulrich Drepper <drepper@gnu.org>, 1995.
 
    This file is part of the GNU C Library.  Its master source is NOT part of
    the C library, however.
@@ -212,6 +212,7 @@ free_mem (void)
       if (runp->data != NULL)
 	_nl_unload_domain ((struct loaded_domain *) runp->data);
       runp = runp->next;
+      free ((char *) here->filename);
       free (here);
     }
 }
diff --git a/locale/findlocale.c b/locale/findlocale.c
index af2b36439e..94f01b4132 100644
--- a/locale/findlocale.c
+++ b/locale/findlocale.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
+   Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public License as
@@ -88,7 +88,7 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
     loc_name = (char *) *name;
 
   /* Make a writable copy of the locale name.  */
-  loc_name = __strdup (loc_name);
+  loc_name = strdupa (loc_name);
 
   /* LOCALE can consist of up to four recognized parts for the XPG syntax:
 
@@ -137,11 +137,6 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
 	/* This means we are out of core.  */
 	return NULL;
     }
-  else
-    /* If the addressed locale is already available it should be
-       freed.  If we would not do this switching back and force
-       between two locales would slowly eat up all memory.  */
-    free ((void *) loc_name);
 
   if (locale_file->decided == 0)
     _nl_load_locale (locale_file, category);
@@ -238,11 +233,11 @@ _nl_remove_locale (int locale, struct locale_data *data)
 static void __attribute__ ((unused))
 free_mem (void)
 {
-  int locale;
+  int category;
 
-  for (locale = 0; locale < LC_ALL; ++locale)
+  for (category = 0; category < LC_ALL; ++category)
     {
-      struct loaded_l10nfile *runp = locale_file_list[locale];
+      struct loaded_l10nfile *runp = locale_file_list[category];
 
       while (runp != NULL)
 	{
@@ -252,6 +247,7 @@ free_mem (void)
 	  if (data != NULL && data->usage_count != UNDELETABLE)
 	    _nl_unload_locale (data);
 	  runp = runp->next;
+	  free ((char *) here->filename);
 	  free (here);
 	}
     }
diff --git a/locale/setlocale.c b/locale/setlocale.c
index cde5b6a4fc..0f685bc355 100644
--- a/locale/setlocale.c
+++ b/locale/setlocale.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 95, 96, 97, 98 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -391,3 +391,25 @@ setlocale (int category, const char *locale)
       return (char *) newname[0];
     }
 }
+
+
+static void __attribute__ ((unused))
+free_mem (void)
+{
+  int category;
+
+  for (category = 0; category < LC_ALL; ++category)
+    {
+      struct locale_data *here = *_nl_current[category];
+
+      /* We have to be prepared that sometime later me still might
+	 need the locale information.  */
+      *_nl_current[category] = _nl_C[category];
+      setname (category, _nl_C_name);
+
+      _nl_unload_locale (here);
+    }
+
+  setname (LC_ALL, _nl_C_name);
+}
+text_set_element (__libc_subfreeres, free_mem);