* locale/newlocale.c (__newlocale): If setting all categories to "C",
just return &_nl_C_locobj instead of copying it.
* locale/freelocale.c (__freelocale): Check for &_nl_C_locobj.
* locale/duplocale.c (__duplocale): Likewise.
__locale_t
__duplocale (__locale_t dataset)
{
+ /* This static object is returned for newlocale (LC_ALL_MASK, "C"). */
+ if (dataset == &_nl_C_locobj)
+ return dataset;
+
__locale_t result;
int cnt;
size_t names_len = 0;
{
int cnt;
+ /* This static object is returned for newlocale (LC_ALL_MASK, "C"). */
+ if (dataset == &_nl_C_locobj)
+ return;
+
/* We modify global data (the usage counts). */
__libc_lock_lock (__libc_setlocale_lock);
if (locale == NULL)
ERROR_RETURN;
+ if (base == &_nl_C_locobj)
+ /* We're to modify BASE, returned for a previous call with "C".
+ We can't really modify the read-only structure, so instead
+ start over by copying it. */
+ base = NULL;
+
+ if ((base == NULL || category_mask == (1 << __LC_LAST) - 1 - (1 << LC_ALL))
+ && (category_mask == 0 || !strcmp (locale, "C")))
+ /* Asking for the "C" locale needn't allocate a new object. */
+ return &_nl_C_locobj;
+
/* Allocate memory for the result. */
if (base != NULL)
result = *base;