strdupa(3) the result of setlocale(3)
Mark Brown
m.steven.brown@gmail.com
Sun Jul 27 22:10:48 GMT 2025
On 7/22/25 7:01 PM, Alejandro Colomar via Libc-help wrote:
> I'm assuming setlocale(3) will only ever return small strings, and thus
> it would be safe to call strdupa(3) on those. Is it a safe assumption?
> Is there any circumstance under which this might not be correct?
No, you cannot assume anything about the size of the string, it is
technically "opaque". For example
setlocale( LC_ALL, NULL);
returns one of these:
locale-name
locale-name-list: locale-name1,locale-name2,…, (if different names
for one or more categories.)
and if the locale is custom-created, this could possibly be long(?).
--
Mark Brown
mstevenbrown@gmail.com
More information about the Libc-help
mailing list