MattWoberts
Programmer
Hi all,
I'm out of practice with Visual C++, but recently had to take a look at some old code. I noticed this function which returns a date as a string:
This is fine (I think). However, it gets called quite a lot, generally when building a string. It gets called like this:
Now what I noticed was that this 12 byte allocation is not being cleared up !! Am I right in thinking this will eat up more and more memory as it continues to run?
Many thanks!
Matt
I'm out of practice with Visual C++, but recently had to take a look at some old code. I noticed this function which returns a date as a string:
Code:
wchar_t * MyClass::GetDate()
{
wchar_t * sText;
sText = new wchar_t [12];
// Populate sText with a date....
return sText
}
This is fine (I think). However, it gets called quite a lot, generally when building a string. It gets called like this:
Code:
basic_stringstream<wchar_t> sString;
sString << L"Some text " << class.GetDate() << L".";
Now what I noticed was that this 12 byte allocation is not being cleared up !! Am I right in thinking this will eat up more and more memory as it continues to run?
Many thanks!
Matt