May 11th, 2010, 11:20 PM
Cleaning up strings
Given this code, I want to make sure that there are no leaks from the strings that I have used:
string varVarName = GetAttribute("VarIn", pNodeMap);
string stringIn = getDictionary(varVarName);
CString cstrIn = CString(stringIn.c_str());
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.?
Tags for this Thread
Click Here to Expand Forum to Full Width