diff options
Diffstat (limited to 'locale')
-rw-r--r-- | locale/loadlocale.c | 18 | ||||
-rw-r--r-- | locale/localeinfo.h | 3 | ||||
-rw-r--r-- | locale/setlocale.c | 44 |
3 files changed, 9 insertions, 56 deletions
diff --git a/locale/loadlocale.c b/locale/loadlocale.c index d465ed1..5894b07 100644 --- a/locale/loadlocale.c +++ b/locale/loadlocale.c @@ -217,21 +217,3 @@ _nl_load_locale (struct loaded_l10nfile *file, int category) __close (fd); file->data = newdata; } - -void -_nl_free_locale (const struct locale_data *data) -{ - int save = errno; - if (data == NULL) - /* Ignore a null pointer, like free does. */ - return; - if (data->name != NULL) - free ((void *) data->name); - if (__munmap ((caddr_t) data->filedata, data->filesize) < 0) - { - if (errno == ENOSYS) - free ((void *) data->filedata); - errno = save; - } - free ((void *) data); -} diff --git a/locale/localeinfo.h b/locale/localeinfo.h index 2b7c6fa..0646f0e 100644 --- a/locale/localeinfo.h +++ b/locale/localeinfo.h @@ -113,9 +113,6 @@ extern const 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 the locale data read in by a `_nl_load_locale' call. */ -extern void _nl_free_locale (const struct locale_data *); - /* Global variables for LC_COLLATE category data. */ extern const u_int32_t *__collate_table; diff --git a/locale/setlocale.c b/locale/setlocale.c index 4eeb5b3..d0d9223 100644 --- a/locale/setlocale.c +++ b/locale/setlocale.c @@ -326,40 +326,22 @@ setlocale (int category, const char *locale) &newnames[category]); if (newdata[category] == NULL) - goto abort_composite; + break; } else { /* The data is never used; just change the name. */ newnames[category] = clever_copy (newnames[category]); if (newnames[category] == NULL) - goto abort_composite; + break; } /* Create new composite name. */ - composite = new_composite_name (LC_ALL, newnames); - if (composite == NULL) - { - /* Loading this part of the locale failed. Abort the - composite load. */ - int save_errno; - - category = -1; - abort_composite: - save_errno = errno; - - while (++category < LC_ALL) - if (_nl_current[category] != NULL - && newdata[category] != _nl_C[category]) - _nl_free_locale (newdata[category]); - else - if (_nl_current[category] == NULL - && newnames[category] != _nl_C_name) - free (newnames[category]); - - errno = save_errno; - composite = NULL; - } + if (category >= 0 + || (composite = new_composite_name (LC_ALL, newnames)) == NULL) + /* Loading this part of the locale failed. Abort the + composite load. */ + composite = NULL; else { /* Now we have loaded all the new data. Put it in place. */ @@ -379,7 +361,7 @@ setlocale (int category, const char *locale) else { const struct locale_data *newdata = NULL; - char *newname = NULL; + char *newname = (char *) locale; /* Protect global data. */ __libc_lock_lock (lock); @@ -387,7 +369,6 @@ setlocale (int category, const char *locale) if (_nl_current[category] != NULL) { /* Only actually load the data if anything will use it. */ - newname = (char *) locale; newdata = _nl_find_locale (locale_path, locale_path_len, category, (char **) &newname); if (newdata == NULL) @@ -398,14 +379,7 @@ setlocale (int category, const char *locale) composite = new_composite_name (category, &newname); if (composite == NULL) { - /* If anything went wrong free what we managed to allocate - so far. */ - int save_errno = errno; - - if (_nl_current[category] != NULL) - _nl_free_locale (newdata); - - errno = save_errno; + /* Say that we don't have any data loaded. */ abort_single: newname = NULL; } |