Unfortunately I don't have VC2005. I am using Visual Studio C++ Version 6.0.
"Joseph M. Newcomer" wrote:
I find this asserstion somewhat less than credible. I just tried both the Debug and
Release versions of VS2005, calling GetTextExtent. It created a CString, and deleted it.
In fact, the code is (snapshot from the running code)
DEBUG code:
CSize sz = dc.GetTextExtent(_T("ABCDEFG"));
004128F5 mov esi,esp
004128F7 push offset string L"ABCDEFG" (41CDE8h)
004128FC lea ecx,[ebp-130h]
00412902 call dword ptr [__imp_ATL::CStringT
<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >::
CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >
(42185Ch)]
-----
or eliminating the fluff, it just called CString::CString(_T("ABCDEFG"));
-----
00412908 cmp esi,esp
0041290A call @ILT+1370(__RTC_CheckEsp) (41155Fh)
0041290F mov byte ptr [ebp-4],2
00412913 lea eax,[ebp-130h]
00412919 push eax
0041291A lea ecx,[ebp-58h]
0041291D push ecx
0041291E lea ecx,[ebp-48h]
00412921 call CDC::GetTextExtent (411393h)
00412926 mov byte ptr [ebp-4],1
0041292A mov esi,esp
0041292C lea ecx,[ebp-130h]
00412932 call dword ptr
[__imp_ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >
::~CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t> > >
(421868h)]
-----
or, it just called CString::~CString as the temporary object just left scope. I singled
stepped through both the debug and release code and watched it delete the CString object
and free its associated storage
-----
00412938 cmp esi,esp
0041293A call @ILT+1370(__RTC_CheckEsp) (41155Fh)
RELEASE version:
CSize sz = dc.GetTextExtent(_T("ABCDEFG"));
004012B5 push offset string L"ABCDEFG" (4035A8h)
004012BA lea ecx,[esp+14h]
004012BE mov dword ptr [esp+3Ch],1
004012C6 call dword ptr
[__imp_ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t> >
::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > (4030FCh)]
004012CC mov eax,dword ptr [esp+10h]
004012D0 mov ecx,dword ptr [eax-0Ch]
004012D3 lea edx,[esp+14h]
004012D7 push edx
004012D8 push ecx
004012D9 push eax
004012DA mov eax,dword ptr [esp+30h]
004012DE push eax
004012DF call dword ptr [__imp__GetTextExtentPoint32W@16 (403008h)]
004012E5 lea ecx,[esp+10h]
004012E9 call dword ptr
[__imp_ATL::CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t> >
::~CStringT<wchar_t,StrTraitMFC_DLL<wchar_t,ATL::ChTraitsCRT<wchar_t> > > (4030ECh)]