What's wrong with this C++ function?
I am trying to get the root cause of memory corruption in a C++
multi-threaded application. When I turn on gflags with "Enable Page Heap",
I am getting access violation consistently, when the following function
returns. This function is being called in many different threads at the
same time. Here is a modified version of the same function:-
std::string CNetWorkerThreadB::TranslateFunctionNumberToText(int
iFunction)
{
std::string strFunctText = "";
if (iFunction & 1)
{
strFunctText = "DPF, ";
}
if (iFunction & 2)
{
strFunctText.append("TC, ");
}
if (iFunction & 3)
{
strFunctText.append("PRV, ");
}
if (strFunctText.length() < 2)
{
return strFunctText;
}
return strFunctText.substr(0, strFunctText.length() - 2);
}
No comments:
Post a Comment