From: Daniel Lehman Subject: [PATCH] msvcp90: Implement time_get ctors and dtors Message-Id: <2EE9C16F5A58104387BC411DC1EFA8F9EED3B92D@RED-INF-EXMB-P1.esri.com> Date: Fri, 26 Jun 2015 14:51:13 +0000 From a674b5493344eefb15ceee539db19afb3d9158e5 Mon Sep 17 00:00:00 2001 From: Daniel Lehman Date: Mon, 22 Jun 2015 17:45:28 -0700 Subject: [PATCH] msvcp90: Implement time_get ctors and dtors (Valgrind) re-arranges functions so that time_get_char_ctor_name can call time_get_char_ctor_locinfo ==944== 560 bytes in 7 blocks are definitely lost in loss record 143 of 158 ==944== at 0x4C52D8C: RtlAllocateHeap (in wine/lib64/wine/ntdll.dll.so) ==944== by 0x9D0AA83: msvcrt_heap_alloc (heap.c:70) ==944== by 0x9D0AD93: MSVCRT_operator_new (heap.c:137) ==944== by 0x9A1C03B: locale__Locimp__Makexloc (locale.c:10505) ==944== by 0x9A1C47A: locale__Locimp__Makeloc (locale.c:10554) ==944== by 0x1400010D9: std::locale::_Construct (xlocale:359) ==944== by 0x994FC5F: ??? ==944== by 0x3E: ??? ==944== by 0x9FB357F: ??? --- dlls/msvcp90/locale.c | 68 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/dlls/msvcp90/locale.c b/dlls/msvcp90/locale.c index b9deffe..0deda0a 100644 --- a/dlls/msvcp90/locale.c +++ b/dlls/msvcp90/locale.c @@ -9665,17 +9665,26 @@ extern const vtable_ptr MSVCP_time_get_char_vtable; DEFINE_THISCALL_WRAPPER(time_get_char__Init, 8) void __thiscall time_get_char__Init(time_get_char *this, const _Locinfo *locinfo) { - FIXME("(%p %p) stub\n", this, locinfo); -} + const char *months; + const char *days; + int len; -/* ??0?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@IAE@PBDI@Z */ -/* ??0?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@IEAA@PEBD_K@Z */ -DEFINE_THISCALL_WRAPPER(time_get_char_ctor_name, 12) -time_get_char* __thiscall time_get_char_ctor_name(time_get_char *this, const char *name, unsigned int refs) -{ - FIXME("(%p %p %d) stub\n", this, name, refs); - this->facet.vtable = &MSVCP_time_get_char_vtable; - return NULL; + TRACE("(%p %p)\n", this, locinfo); + + days = _Locinfo__Getdays((_Locinfo *)locinfo); + len = strlen(days)+1; + this->days = MSVCRT_operator_new(len); + if(this->days) + memcpy((char*)this->days, days, len); + + months = _Locinfo__Getmonths((_Locinfo *)locinfo); + len = strlen(months)+1; + this->months = MSVCRT_operator_new(len); + if(this->months) + memcpy((char*)this->months, months, len); + + this->dateorder = _Locinfo__Getdateorder(locinfo); + _Locinfo__Getcvt(locinfo, &this->cvt); } /* ??0?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@QAE@ABV_Locinfo@1@I@Z */ @@ -9684,19 +9693,41 @@ DEFINE_THISCALL_WRAPPER(time_get_char_ctor_locinfo, 12) time_get_char* __thiscall time_get_char_ctor_locinfo(time_get_char *this, const _Locinfo *locinfo, unsigned int refs) { - FIXME("(%p %p %d) stub\n", this, locinfo, refs); + TRACE("(%p %p %d)\n", this, locinfo, refs); + locale_facet_ctor_refs(&this->facet, refs); this->facet.vtable = &MSVCP_time_get_char_vtable; + time_get_char__Init(this, locinfo); return NULL; } +/* ??0?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@IAE@PBDI@Z */ +/* ??0?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@IEAA@PEBD_K@Z */ +DEFINE_THISCALL_WRAPPER(time_get_char_ctor_name, 12) +time_get_char* __thiscall time_get_char_ctor_name(time_get_char *this, const char *name, unsigned int refs) +{ + _Locinfo locinfo; + + TRACE("(%p %u)\n", this, refs); + + _Locinfo_ctor_cstr(&locinfo, name); + time_get_char_ctor_locinfo(this, &locinfo, refs); + _Locinfo_dtor(&locinfo); + return this; +} + /* ??0?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@QAE@I@Z */ /* ??0?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@QEAA@_K@Z */ DEFINE_THISCALL_WRAPPER(time_get_char_ctor_refs, 8) time_get_char* __thiscall time_get_char_ctor_refs(time_get_char *this, unsigned int refs) { - FIXME("(%p %d) stub\n", this, refs); - this->facet.vtable = &MSVCP_time_get_char_vtable; - return NULL; + _Locinfo locinfo; + + TRACE("(%p %u)\n", this, refs); + + _Locinfo_ctor(&locinfo); + time_get_char_ctor_locinfo(this, &locinfo, refs); + _Locinfo_dtor(&locinfo); + return this; } /* ??_F?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@QAEXXZ */ @@ -9712,7 +9743,10 @@ time_get_char* __thiscall time_get_char_ctor(time_get_char *this) DEFINE_THISCALL_WRAPPER(time_get_char__Tidy, 4) void __thiscall time_get_char__Tidy(time_get_char *this) { - FIXME("(%p) stub\n", this); + TRACE("(%p)\n", this); + + MSVCRT_operator_delete((char*)this->days); + MSVCRT_operator_delete((char*)this->months); } /* ??1?$time_get@DV?$istreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@MAE@XZ */ @@ -9720,7 +9754,9 @@ void __thiscall time_get_char__Tidy(time_get_char *this) DEFINE_THISCALL_WRAPPER(time_get_char_dtor, 4) /* virtual */ void __thiscall time_get_char_dtor(time_get_char *this) { - FIXME("(%p) stub\n", this); + TRACE("(%p)\n", this); + + time_get_char__Tidy(this); } DEFINE_THISCALL_WRAPPER(time_get_char_vector_dtor, 8) -- 1.9.5