Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/msvcrt/locale.c | 32 ++++++++++++++++++++++++++++++-- dlls/msvcrt/msvcrt.h | 2 ++ 2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcrt/locale.c b/dlls/msvcrt/locale.c index f25c1228d2f..0b423387368 100644 --- a/dlls/msvcrt/locale.c +++ b/dlls/msvcrt/locale.c @@ -953,6 +953,34 @@ void free_mbcinfo(MSVCRT_pthreadmbcinfo mbcinfo) MSVCRT_free(mbcinfo); }
+MSVCRT__locale_t CDECL get_current_locale_noalloc(MSVCRT__locale_t locale) +{ + thread_data_t *data = msvcrt_get_thread_data(); + + if(!locale) + return NULL; + + if(!data || !data->have_locale) + { + locale->locinfo = MSVCRT_locale->locinfo; + locale->mbcinfo = MSVCRT_locale->mbcinfo; + /* FIXME: update locinfo/mbcinfo refcount */ + } + else + { + locale->locinfo = data->locinfo; + locale->mbcinfo = data->mbcinfo; + } + return locale; +} + +void CDECL free_locale_noalloc(MSVCRT__locale_t locale) +{ + if (!locale) + return; + /* FIXME: update locinfo/mbcinfo refcount */ +} + /********************************************************************* * _get_current_locale (MSVCRT.@) */ @@ -962,8 +990,7 @@ MSVCRT__locale_t CDECL MSVCRT__get_current_locale(void) if(!loc) return NULL;
- loc->locinfo = get_locinfo(); - loc->mbcinfo = get_mbcinfo(); + get_current_locale_noalloc(loc); InterlockedIncrement(&loc->locinfo->refcount); InterlockedIncrement(&loc->mbcinfo->refcount); return loc; @@ -977,6 +1004,7 @@ void CDECL MSVCRT__free_locale(MSVCRT__locale_t locale) if (!locale) return;
+ free_locale_noalloc(locale); free_locinfo(locale->locinfo); free_mbcinfo(locale->mbcinfo); MSVCRT_free(locale); diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index f73117ae5e2..07a2f3d33e8 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -1128,6 +1128,8 @@ int __cdecl MSVCRT__set_printf_count_output(int); #define MSVCRT__DISABLE_PER_THREAD_LOCALE 2
extern MSVCRT__locale_t MSVCRT_locale; +MSVCRT__locale_t CDECL get_current_locale_noalloc(MSVCRT__locale_t locale) DECLSPEC_HIDDEN; +void CDECL free_locale_noalloc(MSVCRT__locale_t locale) DECLSPEC_HIDDEN; MSVCRT_pthreadlocinfo CDECL get_locinfo(void) DECLSPEC_HIDDEN; MSVCRT_pthreadmbcinfo CDECL get_mbcinfo(void) DECLSPEC_HIDDEN; void __cdecl MSVCRT__free_locale(MSVCRT__locale_t);