locale_t duplocale(locale_t loc);
duplocale duplicates the locale object referenced by loc.
If there is insufficient memory to duplicate loc, duplocale returns NULL and sets errno to ENOMEM as required by POSIX.1-2008.
Duplicated locales must be freed with freelocale.
This is different behavior from the GNU glibc implementation which makes no mention of setting errno on failure.
This extension is derived from BSD, POSIX.1, and glibc.