I have a class that contains a a string. Currently, it's an std::wstring but does not have to be. I had read here that std::string should not be used but I am wondering if something like this would work:
if (aString.length() == aString.capacity() )
{
std::wstring oldString = aString;
aString = wstring(aString);
aString.reserve(PREALLOCATION_AMOUNT);
SecureZeroMemory((PVOID)oldString.c_str(),oldString.size());
oldString.clear();
}
would this basically equate to a secure realloc of the string buffer? If not is there a better solution?