Signed-off-by: Chip Davis cdavis@codeweavers.com --- v2: Fix build. --- dlls/msvcr90/tests/msvcr90.c | 44 ++++++++++++++++++------------------ dlls/msvcrt/locale.c | 24 ++++++++++++++++++-- 2 files changed, 44 insertions(+), 24 deletions(-)
diff --git a/dlls/msvcr90/tests/msvcr90.c b/dlls/msvcr90/tests/msvcr90.c index ec183d9be173..52e135d1e011 100644 --- a/dlls/msvcr90/tests/msvcr90.c +++ b/dlls/msvcr90/tests/msvcr90.c @@ -2021,14 +2021,14 @@ static void test__get_current_locale(void) "same refcount pointers for LC_COLLATE\n"); ok(*l->locinfo->lc_category[LC_COLLATE].refcount == 1, "refcount = %d\n", *l->locinfo->lc_category[LC_COLLATE].refcount); - todo_wine ok(*l2->locinfo->lc_category[LC_COLLATE].refcount == 2, "refcount = %d\n", + ok(*l2->locinfo->lc_category[LC_COLLATE].refcount == 2, "refcount = %d\n", *l2->locinfo->lc_category[LC_COLLATE].refcount); for(i = LC_CTYPE; i <= LC_MAX; i++) { ok(l->locinfo->lc_category[i].locale == l2->locinfo->lc_category[i].locale, "different locale name pointers for category %d\n", i); ok(l->locinfo->lc_category[i].refcount == l2->locinfo->lc_category[i].refcount, "different refcount pointers for category %d\n", i); - todo_wine ok(*l->locinfo->lc_category[i].refcount == 3, "refcount = %d for category %d\n", + ok(*l->locinfo->lc_category[i].refcount == 3, "refcount = %d for category %d\n", *l->locinfo->lc_category[i].refcount, i); }
@@ -2045,23 +2045,23 @@ static void test__get_current_locale(void) ok(l->locinfo->pclmap == l2->locinfo->pclmap, "different clmap pointers\n"); ok(l->locinfo->pcumap == l2->locinfo->pcumap, "different cumap pointers\n"); ok(l->locinfo->ctype1_refcount == l2->locinfo->ctype1_refcount, "different ctype1_refcount pointers\n"); - todo_wine ok(*l->locinfo->ctype1_refcount == 3, "refcount = %d\n", *l->locinfo->ctype1_refcount); + ok(*l->locinfo->ctype1_refcount == 3, "refcount = %d\n", *l->locinfo->ctype1_refcount);
ok(l->locinfo->lconv == l2->locinfo->lconv, "different lconv pointers\n"); ok(l->locinfo->lconv_intl_refcount == l2->locinfo->lconv_intl_refcount, "different lconv_intl_refcount pointers\n"); - todo_wine ok(*l->locinfo->lconv_intl_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_intl_refcount); + ok(*l->locinfo->lconv_intl_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_intl_refcount);
ok(l->locinfo->lconv->decimal_point == l2->locinfo->lconv->decimal_point, "different LC_NUMERIC pointers\n"); ok(l->locinfo->lconv_num_refcount == l2->locinfo->lconv_num_refcount, "different lconv_num_refcount pointers\n"); - todo_wine ok(*l->locinfo->lconv_num_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_num_refcount); + ok(*l->locinfo->lconv_num_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_num_refcount);
ok(l->locinfo->lconv->currency_symbol == l2->locinfo->lconv->currency_symbol, "different LC_MONETARY pointers\n"); ok(l->locinfo->lconv_mon_refcount == l2->locinfo->lconv_mon_refcount, "different lconv_mon_refcount pointers\n"); - todo_wine ok(*l->locinfo->lconv_mon_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_mon_refcount); + ok(*l->locinfo->lconv_mon_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_mon_refcount);
ok(l->locinfo->lc_time_curr == l2->locinfo->lc_time_curr, "different lc_time_curr pointers\n"); ok(l->locinfo->lc_time_curr->unk == 1, "unk = %d\n", l->locinfo->lc_time_curr->unk); - todo_wine ok(l->locinfo->lc_time_curr->refcount == 3, "refcount = %d\n", l->locinfo->lc_time_curr->refcount); + ok(l->locinfo->lc_time_curr->refcount == 3, "refcount = %d\n", l->locinfo->lc_time_curr->refcount);
p__free_locale(l2);
@@ -2078,7 +2078,7 @@ static void test__get_current_locale(void) "same refcount pointers for category %d\n", i); ok(*l->locinfo->lc_category[i].refcount == 1, "refcount = %d for category %d\n", *l->locinfo->lc_category[i].refcount, i); - todo_wine ok(*l2->locinfo->lc_category[i].refcount == 2, "refcount = %d for category %d\n", + ok(*l2->locinfo->lc_category[i].refcount == 2, "refcount = %d for category %d\n", *l2->locinfo->lc_category[i].refcount, i); } for(i = LC_MONETARY; i <= LC_MAX; i++) { @@ -2086,7 +2086,7 @@ static void test__get_current_locale(void) "different locale name pointers for category %d\n", i); ok(l->locinfo->lc_category[i].refcount == l2->locinfo->lc_category[i].refcount, "different refcount pointers for category %d\n", i); - todo_wine ok(*l->locinfo->lc_category[i].refcount == 3, "refcount = %d for category %d\n", + ok(*l->locinfo->lc_category[i].refcount == 3, "refcount = %d for category %d\n", *l->locinfo->lc_category[i].refcount, i); }
@@ -2108,19 +2108,19 @@ static void test__get_current_locale(void)
ok(l->locinfo->lconv == l2->locinfo->lconv, "different lconv pointers\n"); ok(l->locinfo->lconv_intl_refcount == l2->locinfo->lconv_intl_refcount, "different lconv_intl_refcount pointers\n"); - todo_wine ok(*l->locinfo->lconv_intl_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_intl_refcount); + ok(*l->locinfo->lconv_intl_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_intl_refcount);
ok(l->locinfo->lconv->decimal_point == l2->locinfo->lconv->decimal_point, "different LC_NUMERIC pointers\n"); ok(l->locinfo->lconv_num_refcount == l2->locinfo->lconv_num_refcount, "different lconv_num_refcount pointers\n"); - todo_wine ok(*l->locinfo->lconv_num_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_num_refcount); + ok(*l->locinfo->lconv_num_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_num_refcount);
ok(l->locinfo->lconv->currency_symbol == l2->locinfo->lconv->currency_symbol, "different LC_MONETARY pointers\n"); ok(l->locinfo->lconv_mon_refcount == l2->locinfo->lconv_mon_refcount, "different lconv_mon_refcount pointers\n"); - todo_wine ok(*l->locinfo->lconv_mon_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_mon_refcount); + ok(*l->locinfo->lconv_mon_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_mon_refcount);
ok(l->locinfo->lc_time_curr == l2->locinfo->lc_time_curr, "different lc_time_curr pointers\n"); ok(l->locinfo->lc_time_curr->unk == 1, "unk = %d\n", l->locinfo->lc_time_curr->unk); - todo_wine ok(l->locinfo->lc_time_curr->refcount == 3, "refcount = %d\n", l->locinfo->lc_time_curr->refcount); + ok(l->locinfo->lc_time_curr->refcount == 3, "refcount = %d\n", l->locinfo->lc_time_curr->refcount);
p__free_locale(l2);
@@ -2137,7 +2137,7 @@ static void test__get_current_locale(void) "same refcount pointers for category %d\n", i); ok(*l->locinfo->lc_category[i].refcount == 1, "refcount = %d for category %d\n", *l->locinfo->lc_category[i].refcount, i); - todo_wine ok(*l2->locinfo->lc_category[i].refcount == 2, "refcount = %d for category %d\n", + ok(*l2->locinfo->lc_category[i].refcount == 2, "refcount = %d for category %d\n", *l2->locinfo->lc_category[i].refcount, i); } for(i = LC_NUMERIC; i <= LC_MAX; i++) { @@ -2145,7 +2145,7 @@ static void test__get_current_locale(void) "different locale name pointers for category %d\n", i); ok(l->locinfo->lc_category[i].refcount == l2->locinfo->lc_category[i].refcount, "different refcount pointers for category %d\n", i); - todo_wine ok(*l->locinfo->lc_category[i].refcount == 3, "refcount = %d for category %d\n", + ok(*l->locinfo->lc_category[i].refcount == 3, "refcount = %d for category %d\n", *l->locinfo->lc_category[i].refcount, i); }
@@ -2168,11 +2168,11 @@ static void test__get_current_locale(void) ok(l->locinfo->lconv != l2->locinfo->lconv, "same lconv pointers\n"); ok(l->locinfo->lconv_intl_refcount != l2->locinfo->lconv_intl_refcount, "same lconv_intl_refcount pointers\n"); ok(*l->locinfo->lconv_intl_refcount == 1, "refcount = %d\n", *l->locinfo->lconv_intl_refcount); - todo_wine ok(*l2->locinfo->lconv_intl_refcount == 2, "refcount = %d\n", *l2->locinfo->lconv_intl_refcount); + ok(*l2->locinfo->lconv_intl_refcount == 2, "refcount = %d\n", *l2->locinfo->lconv_intl_refcount);
ok(l->locinfo->lconv->decimal_point == l2->locinfo->lconv->decimal_point, "different LC_NUMERIC pointers\n"); ok(l->locinfo->lconv_num_refcount == l2->locinfo->lconv_num_refcount, "different lconv_num_refcount pointers\n"); - todo_wine ok(*l->locinfo->lconv_num_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_num_refcount); + ok(*l->locinfo->lconv_num_refcount == 3, "refcount = %d\n", *l->locinfo->lconv_num_refcount);
ok(l->locinfo->lconv->currency_symbol != l2->locinfo->lconv->currency_symbol, "same LC_MONETARY pointers\n"); ok(l->locinfo->lconv_mon_refcount != l2->locinfo->lconv_mon_refcount, "same lconv_mon_refcount pointers\n"); @@ -2181,7 +2181,7 @@ static void test__get_current_locale(void)
ok(l->locinfo->lc_time_curr == l2->locinfo->lc_time_curr, "different lc_time_curr pointers\n"); ok(l->locinfo->lc_time_curr->unk == 1, "unk = %d\n", l->locinfo->lc_time_curr->unk); - todo_wine ok(l->locinfo->lc_time_curr->refcount == 3, "refcount = %d\n", l->locinfo->lc_time_curr->refcount); + ok(l->locinfo->lc_time_curr->refcount == 3, "refcount = %d\n", l->locinfo->lc_time_curr->refcount);
p__free_locale(l2);
@@ -2198,14 +2198,14 @@ static void test__get_current_locale(void) "same refcount pointers for category %d\n", i); ok(*l->locinfo->lc_category[i].refcount == 1, "refcount = %d for category %d\n", *l->locinfo->lc_category[i].refcount, i); - todo_wine ok(*l2->locinfo->lc_category[i].refcount == 2, "refcount = %d for category %d\n", + ok(*l2->locinfo->lc_category[i].refcount == 2, "refcount = %d for category %d\n", *l2->locinfo->lc_category[i].refcount, i); } ok(l->locinfo->lc_category[LC_TIME].locale == l2->locinfo->lc_category[LC_TIME].locale, "different locale name pointers for LC_TIME\n"); ok(l->locinfo->lc_category[LC_TIME].refcount == l2->locinfo->lc_category[LC_TIME].refcount, "different refcount pointers for LC_TIME\n"); - todo_wine ok(*l->locinfo->lc_category[LC_TIME].refcount == 3, "refcount = %d\n", + ok(*l->locinfo->lc_category[LC_TIME].refcount == 3, "refcount = %d\n", *l->locinfo->lc_category[LC_TIME].refcount);
ok(l->locinfo->lc_collate_cp != l2->locinfo->lc_collate_cp, "same lc_collate_cp %u, %u\n", @@ -2241,7 +2241,7 @@ static void test__get_current_locale(void)
ok(l->locinfo->lc_time_curr == l2->locinfo->lc_time_curr, "different lc_time_curr pointers\n"); ok(l->locinfo->lc_time_curr->unk == 1, "unk = %d\n", l->locinfo->lc_time_curr->unk); - todo_wine ok(l->locinfo->lc_time_curr->refcount == 3, "refcount = %d\n", l->locinfo->lc_time_curr->refcount); + ok(l->locinfo->lc_time_curr->refcount == 3, "refcount = %d\n", l->locinfo->lc_time_curr->refcount);
p__free_locale(l2);
@@ -2258,7 +2258,7 @@ static void test__get_current_locale(void) "same refcount pointers for category %d\n", i); ok(*l->locinfo->lc_category[i].refcount == 1, "refcount = %d for category %d\n", *l->locinfo->lc_category[i].refcount, i); - todo_wine ok(*l2->locinfo->lc_category[i].refcount == 2, "refcount = %d for category %d\n", + ok(*l2->locinfo->lc_category[i].refcount == 2, "refcount = %d for category %d\n", *l2->locinfo->lc_category[i].refcount, i); }
diff --git a/dlls/msvcrt/locale.c b/dlls/msvcrt/locale.c index 6210039eca16..4d7ef6663b67 100644 --- a/dlls/msvcrt/locale.c +++ b/dlls/msvcrt/locale.c @@ -915,6 +915,27 @@ int CDECL ___lc_collate_cp_func(void) return get_locinfo()->lc_collate_cp; }
+/* INTERNAL: increases all reference counts in threadlocinfo struct */ +MSVCRT_pthreadlocinfo grab_locinfo(MSVCRT_pthreadlocinfo locinfo) +{ + int i; + + InterlockedIncrement(&locinfo->refcount); + for(i=MSVCRT_LC_MIN+1; i<=MSVCRT_LC_MAX; i++) + InterlockedIncrement(locinfo->lc_category[i].refcount); + if(locinfo->lconv_intl_refcount) + InterlockedIncrement(locinfo->lconv_intl_refcount); + if(locinfo->lconv_num_refcount) + InterlockedIncrement(locinfo->lconv_num_refcount); + if(locinfo->lconv_mon_refcount) + InterlockedIncrement(locinfo->lconv_mon_refcount); + if(locinfo->ctype1_refcount) + InterlockedIncrement(locinfo->ctype1_refcount); + InterlockedIncrement(&locinfo->lc_time_curr->refcount); + + return locinfo; +} + /* INTERNAL: frees MSVCRT_pthreadlocinfo struct */ void free_locinfo(MSVCRT_pthreadlocinfo locinfo) { @@ -1009,9 +1030,8 @@ MSVCRT__locale_t CDECL MSVCRT__get_current_locale(void) if(!loc) return NULL;
- loc->locinfo = get_locinfo(); + loc->locinfo = grab_locinfo(get_locinfo()); loc->mbcinfo = get_mbcinfo(); - InterlockedIncrement(&loc->locinfo->refcount); InterlockedIncrement(&loc->mbcinfo->refcount); return loc; }