about summary refs log tree commit diff
path: root/locale/loadlocale.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2022-05-23 10:08:18 +0200
committerFlorian Weimer <fweimer@redhat.com>2022-05-23 11:06:31 +0200
commitbbebe83a2874cd25934046d908824dfc11711a2b (patch)
tree1e4b6818e4fc8c35996da79471d55048095f7650 /locale/loadlocale.c
parent0b6342e769be6903f29da067f5cbcbfcc7c01b10 (diff)
downloadglibc-bbebe83a2874cd25934046d908824dfc11711a2b.tar.gz
glibc-bbebe83a2874cd25934046d908824dfc11711a2b.tar.xz
glibc-bbebe83a2874cd25934046d908824dfc11711a2b.zip
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>
Diffstat (limited to 'locale/loadlocale.c')
-rw-r--r--locale/loadlocale.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/locale/loadlocale.c b/locale/loadlocale.c
index b8cd1aa441..9069bafcd8 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -101,8 +101,7 @@ _nl_intern_locale_data (int category, const void *data, size_t datasize)
 
   newdata->filedata = (void *) filedata;
   newdata->filesize = datasize;
-  newdata->private.data = NULL;
-  newdata->private.cleanup = NULL;
+  memset (&newdata->private, 0, sizeof (newdata->private));
   newdata->usage_count = 0;
   newdata->use_translit = 0;
   newdata->nstrings = filedata->nstrings;
@@ -282,10 +281,18 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
 }
 
 void
-_nl_unload_locale (struct __locale_data *locale)
+_nl_unload_locale (int category, struct __locale_data *locale)
 {
-  if (locale->private.cleanup)
-    (*locale->private.cleanup) (locale);
+  /* Deallocate locale->private.  */
+  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))
     {