locale: Remove cleanup function pointer from struct __localedata
We can call the cleanup functions directly from _nl_unload_locale if we pass the category to it. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
parent
0b6342e769
commit
bbebe83a28
|
@ -348,6 +348,6 @@ _nl_remove_locale (int locale, struct __locale_data *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This does the real work. */
|
/* This does the real work. */
|
||||||
_nl_unload_locale (data);
|
_nl_unload_locale (locale, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -515,7 +515,7 @@ _nl_archive_subfreeres (void)
|
||||||
free (dead->name);
|
free (dead->name);
|
||||||
for (category = 0; category < __LC_LAST; ++category)
|
for (category = 0; category < __LC_LAST; ++category)
|
||||||
if (category != LC_ALL && dead->data[category] != NULL)
|
if (category != LC_ALL && dead->data[category] != NULL)
|
||||||
_nl_unload_locale (dead->data[category]);
|
_nl_unload_locale (category, dead->data[category]);
|
||||||
free (dead);
|
free (dead);
|
||||||
}
|
}
|
||||||
archloaded = NULL;
|
archloaded = NULL;
|
||||||
|
|
|
@ -101,8 +101,7 @@ _nl_intern_locale_data (int category, const void *data, size_t datasize)
|
||||||
|
|
||||||
newdata->filedata = (void *) filedata;
|
newdata->filedata = (void *) filedata;
|
||||||
newdata->filesize = datasize;
|
newdata->filesize = datasize;
|
||||||
newdata->private.data = NULL;
|
memset (&newdata->private, 0, sizeof (newdata->private));
|
||||||
newdata->private.cleanup = NULL;
|
|
||||||
newdata->usage_count = 0;
|
newdata->usage_count = 0;
|
||||||
newdata->use_translit = 0;
|
newdata->use_translit = 0;
|
||||||
newdata->nstrings = filedata->nstrings;
|
newdata->nstrings = filedata->nstrings;
|
||||||
|
@ -282,10 +281,18 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_nl_unload_locale (struct __locale_data *locale)
|
_nl_unload_locale (int category, struct __locale_data *locale)
|
||||||
{
|
{
|
||||||
if (locale->private.cleanup)
|
/* Deallocate locale->private. */
|
||||||
(*locale->private.cleanup) (locale);
|
switch (category)
|
||||||
|
{
|
||||||
|
case LC_CTYPE:
|
||||||
|
_nl_cleanup_ctype (locale);
|
||||||
|
break;
|
||||||
|
case LC_TIME:
|
||||||
|
_nl_cleanup_time (locale);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch (__builtin_expect (locale->alloc, ld_mapped))
|
switch (__builtin_expect (locale->alloc, ld_mapped))
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,18 +58,13 @@ struct __locale_data
|
||||||
ld_archive /* Both point into mmap'd archive regions. */
|
ld_archive /* Both point into mmap'd archive regions. */
|
||||||
} alloc;
|
} alloc;
|
||||||
|
|
||||||
/* This provides a slot for category-specific code to cache data computed
|
/* This provides a slot for category-specific code to cache data
|
||||||
about this locale. That code can set a cleanup function to deallocate
|
computed about this locale. This is deallocated at the start of
|
||||||
the data. */
|
_nl_unload_locale. */
|
||||||
struct
|
union
|
||||||
{
|
{
|
||||||
void (*cleanup) (struct __locale_data *);
|
struct lc_time_data *time;
|
||||||
union
|
const struct gconv_fcts *ctype;
|
||||||
{
|
|
||||||
void *data;
|
|
||||||
struct lc_time_data *time;
|
|
||||||
const struct gconv_fcts *ctype;
|
|
||||||
};
|
|
||||||
} private;
|
} private;
|
||||||
|
|
||||||
unsigned int usage_count; /* Counter for users. */
|
unsigned int usage_count; /* Counter for users. */
|
||||||
|
@ -349,7 +344,8 @@ extern void _nl_load_locale (struct loaded_l10nfile *file, int category)
|
||||||
attribute_hidden;
|
attribute_hidden;
|
||||||
|
|
||||||
/* Free all resource. */
|
/* Free all resource. */
|
||||||
extern void _nl_unload_locale (struct __locale_data *locale) attribute_hidden;
|
extern void _nl_unload_locale (int category, struct __locale_data *locale)
|
||||||
|
attribute_hidden;
|
||||||
|
|
||||||
/* Free the locale and give back all memory if the usage count is one. */
|
/* 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)
|
extern void _nl_remove_locale (int locale, struct __locale_data *data)
|
||||||
|
@ -409,7 +405,8 @@ extern int _nl_parse_alt_digit (const char **strp,
|
||||||
/* Postload processing. */
|
/* Postload processing. */
|
||||||
extern void _nl_postload_ctype (void);
|
extern void _nl_postload_ctype (void);
|
||||||
|
|
||||||
/* Functions used for the `private.cleanup' hook. */
|
/* Deallocate category-specific data. Used in _nl_unload_locale. */
|
||||||
|
extern void _nl_cleanup_ctype (struct __locale_data *) attribute_hidden;
|
||||||
extern void _nl_cleanup_time (struct __locale_data *) attribute_hidden;
|
extern void _nl_cleanup_time (struct __locale_data *) attribute_hidden;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -489,7 +489,7 @@ free_category (int category,
|
||||||
struct __locale_data *data = (struct __locale_data *) runp->data;
|
struct __locale_data *data = (struct __locale_data *) runp->data;
|
||||||
|
|
||||||
if (data != NULL && data != c_data)
|
if (data != NULL && data != c_data)
|
||||||
_nl_unload_locale (data);
|
_nl_unload_locale (category, data);
|
||||||
runp = runp->next;
|
runp = runp->next;
|
||||||
free ((char *) curr->filename);
|
free ((char *) curr->filename);
|
||||||
free (curr);
|
free (curr);
|
||||||
|
|
|
@ -41,7 +41,6 @@ _nl_init_alt_digit (struct __locale_data *current)
|
||||||
if (current->private.time == NULL)
|
if (current->private.time == NULL)
|
||||||
return;
|
return;
|
||||||
memset (current->private.time, 0, sizeof *current->private.time);
|
memset (current->private.time, 0, sizeof *current->private.time);
|
||||||
current->private.cleanup = &_nl_cleanup_time;
|
|
||||||
}
|
}
|
||||||
data = current->private.time;
|
data = current->private.time;
|
||||||
|
|
||||||
|
@ -110,7 +109,6 @@ _nl_get_walt_digit (unsigned int number, struct __locale_data *current)
|
||||||
if (current->private.time == NULL)
|
if (current->private.time == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
memset (current->private.time, 0, sizeof *current->private.time);
|
memset (current->private.time, 0, sizeof *current->private.time);
|
||||||
current->private.cleanup = &_nl_cleanup_time;
|
|
||||||
}
|
}
|
||||||
data = current->private.time;
|
data = current->private.time;
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ _nl_init_era_entries (struct __locale_data *current)
|
||||||
if (current->private.time == NULL)
|
if (current->private.time == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
memset (current->private.time, 0, sizeof *current->private.time);
|
memset (current->private.time, 0, sizeof *current->private.time);
|
||||||
current->private.cleanup = &_nl_cleanup_time;
|
|
||||||
}
|
}
|
||||||
data = current->private.time;
|
data = current->private.time;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ _nl_cleanup_time (struct __locale_data *locale)
|
||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
{
|
{
|
||||||
locale->private.time = NULL;
|
locale->private.time = NULL;
|
||||||
locale->private.cleanup = NULL;
|
|
||||||
|
|
||||||
free (data->eras);
|
free (data->eras);
|
||||||
free (data->alt_digits);
|
free (data->alt_digits);
|
||||||
|
|
|
@ -202,10 +202,7 @@ __wcsmbs_load_conv (struct __locale_data *new_category)
|
||||||
new_category->private.ctype = &__wcsmbs_gconv_fcts_c;
|
new_category->private.ctype = &__wcsmbs_gconv_fcts_c;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
new_category->private.ctype = new_fcts;
|
||||||
new_category->private.ctype = new_fcts;
|
|
||||||
new_category->private.cleanup = &_nl_cleanup_ctype;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__libc_rwlock_unlock (__libc_setlocale_lock);
|
__libc_rwlock_unlock (__libc_setlocale_lock);
|
||||||
|
@ -267,10 +264,9 @@ void
|
||||||
_nl_cleanup_ctype (struct __locale_data *locale)
|
_nl_cleanup_ctype (struct __locale_data *locale)
|
||||||
{
|
{
|
||||||
const struct gconv_fcts *const data = locale->private.ctype;
|
const struct gconv_fcts *const data = locale->private.ctype;
|
||||||
if (data != NULL)
|
if (data != NULL && data != &__wcsmbs_gconv_fcts_c)
|
||||||
{
|
{
|
||||||
locale->private.ctype = NULL;
|
locale->private.ctype = NULL;
|
||||||
locale->private.cleanup = NULL;
|
|
||||||
|
|
||||||
/* Free the old conversions. */
|
/* Free the old conversions. */
|
||||||
__gconv_close_transform (data->tomb, data->tomb_nsteps);
|
__gconv_close_transform (data->tomb, data->tomb_nsteps);
|
||||||
|
|
Loading…
Reference in a new issue