use libc-internal malloc for newlocale/freelocale
authorRich Felker <dalias@aerifal.cx>
Wed, 9 Dec 2020 22:11:05 +0000 (17:11 -0500)
committerRich Felker <dalias@aerifal.cx>
Wed, 9 Dec 2020 22:11:05 +0000 (17:11 -0500)
this is necessary for MT-fork correctness now that the code runs under
locale lock. it would not be hard to avoid, but __get_locale is
already using libc-internal malloc anyway. this can be reconsidered
during locale overhaul later if needed.

src/locale/freelocale.c
src/locale/newlocale.c

index 802b8bf..385d120 100644 (file)
@@ -1,6 +1,11 @@
 #include <stdlib.h>
 #include "locale_impl.h"
 
+#define malloc undef
+#define calloc undef
+#define realloc undef
+#define free __libc_free
+
 void freelocale(locale_t l)
 {
        if (__loc_is_allocated(l)) free(l);
index 12ae87d..9ac3cd3 100644 (file)
@@ -4,6 +4,11 @@
 #include "locale_impl.h"
 #include "lock.h"
 
+#define malloc __libc_malloc
+#define calloc undef
+#define realloc undef
+#define free undef
+
 static int default_locale_init_done;
 static struct __locale_struct default_locale, default_ctype_locale;