Will this
result in an invalid memory error?
As far as I understand StdStrBuf, it creates a pointer for the char data and cleans it up in the destructor. So, the destructor is already called after return, thus the method returns a pointer to invalid memory? If I am right, how to solve this?
const char* C4TimeMilliseconds::AsString() const
{
StdStrBuf string;
string.Format("%u:%02u:%02u:%03u:",time / 1000 / 60 / 60, (time / 1000 / 60) % 60, (time / 1000) % 60, time % 1000);
return string.getData();
}
result in an invalid memory error?
As far as I understand StdStrBuf, it creates a pointer for the char data and cleans it up in the destructor. So, the destructor is already called after return, thus the method returns a pointer to invalid memory? If I am right, how to solve this?
Yes, it looks like a memory error. I suggest returning a StdStrBuf (or a StdCopyStrBuf) to fix it.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill