Howdy. I found another leak, this time in ofxXmlSettings.
I’ve spent the past hour trying to find exactly how to stop this leak, but with no luck. Maybe someone else can see what’s wrong here? According to the developer tools, the leak is situated somewhere around here:
string ofxXmlSettings::getValue(string tag, string defaultValue, int which){
// lots of char *, string kung-fu here...
char * tempStr = new char[MAX_TAG_VALUE_LENGTH_IN_CHARS];
memset(tempStr, 0, MAX_TAG_VALUE_LENGTH_IN_CHARS);
char * returnPtr = (char *) defaultValue.c_str();
if (readTag(tag, tempStr, which)){
returnPtr = tempStr;
}
string returnString(returnPtr);
delete tempStr;
return returnString;
}
The leak has something to do obviously with the new and delete, but I can’t figure out how to fix it. I tried making the following change:
delete[] tempStr;
…which seems to me more logical, but it still doesn’t plug up the leak. Perhaps it’s because there is a reference to tempStr still hanging around in the heap (because of readTag()?), but I dunno.