Hi all,
Given this code, I want to make sure that there are no leaks from the strings that I have used:
#include <atlstr.h>
...
string varVarName = GetAttribute("VarIn", pNodeMap);
string stringIn = getDictionary(varVarName);
CString cstrIn = CString(stringIn.c_str());
cstrIn.Trim();
CT2CA pszConvertedAnsiString(cstrIn);
std::string strOut(pszConvertedAnsiString);
From what I understand, I think that I do not need to free std::strings as the program automatically frees those. I am not sure regarding CStrings, although I also believe that the program handles those.
What I know is that from the many string types in C++, only BSTR require freeing if you have called AllocSysString on it or equate it to NULL.
Can you help me understand why you need to free BSTR and not std::string, CString, etc.?
Thank you!