* 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".
This commit is contained in:
Ulrich Drepper 1999-01-28 14:14:08 +00:00
parent d328b80b4e
commit f84ad0b1e0
4 changed files with 39 additions and 14 deletions

View File

@ -1,5 +1,11 @@
1999-01-28 Ulrich Drepper <drepper@cygnus.com> 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 * libio/genops.c (_IO_un_link): Move #ifdef introduced in last
change in right place. change in right place.

View File

@ -1,6 +1,6 @@
/* Handle list of needed message catalogs /* Handle list of needed message catalogs
Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. Written by Ulrich Drepper <drepper@gnu.org>, 1995.
This file is part of the GNU C Library. Its master source is NOT part of This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. the C library, however.
@ -212,6 +212,7 @@ free_mem (void)
if (runp->data != NULL) if (runp->data != NULL)
_nl_unload_domain ((struct loaded_domain *) runp->data); _nl_unload_domain ((struct loaded_domain *) runp->data);
runp = runp->next; runp = runp->next;
free ((char *) here->filename);
free (here); free (here);
} }
} }

View File

@ -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. 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 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 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; loc_name = (char *) *name;
/* Make a writable copy of the locale 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: /* 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. */ /* This means we are out of core. */
return NULL; 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) if (locale_file->decided == 0)
_nl_load_locale (locale_file, category); _nl_load_locale (locale_file, category);
@ -238,11 +233,11 @@ _nl_remove_locale (int locale, struct locale_data *data)
static void __attribute__ ((unused)) static void __attribute__ ((unused))
free_mem (void) 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) while (runp != NULL)
{ {
@ -252,6 +247,7 @@ free_mem (void)
if (data != NULL && data->usage_count != UNDELETABLE) if (data != NULL && data->usage_count != UNDELETABLE)
_nl_unload_locale (data); _nl_unload_locale (data);
runp = runp->next; runp = runp->next;
free ((char *) here->filename);
free (here); free (here);
} }
} }

View File

@ -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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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]; 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);