Use cairo_init_once functions to get C_locale object

This commit is contained in:
Luca Bacci 2026-03-24 11:32:11 +01:00
parent 9a5df2f0db
commit 2e65e01d25

View file

@ -798,26 +798,18 @@ _cairo_get_locale_decimal_point (void)
#if defined (HAVE_NEWLOCALE) && defined (HAVE_STRTOD_L)
static cairo_atomic_once_t C_locale_once;
static locale_t C_locale;
static locale_t
get_C_locale (void)
{
locale_t C;
retry:
C = (locale_t) _cairo_atomic_ptr_get ((cairo_atomic_intptr_t *) &C_locale);
if (unlikely (!C)) {
C = newlocale (LC_ALL_MASK, "C", NULL);
if (!_cairo_atomic_ptr_cmpxchg ((cairo_atomic_intptr_t *) &C_locale, NULL, C)) {
freelocale (C_locale);
goto retry;
}
if (_cairo_atomic_init_once_enter (&C_locale_once)) {
C_locale = newlocale (LC_ALL_MASK, "C", NULL);
_cairo_atomic_init_once_leave (&C_locale_once);
}
return C;
return C_locale;
}
double