It is a good practice to clear container after deleted all the items

This commit is contained in:
seb777 2012-01-19 12:41:14 +01:00
parent 525e7fba20
commit 9be2d1cc62
1 changed files with 3 additions and 2 deletions

View File

@ -2546,7 +2546,7 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file
std::map<std::string, PreprocessorMacro *>::iterator it; std::map<std::string, PreprocessorMacro *>::iterator it;
for (it = macros.begin(); it != macros.end(); ++it) for (it = macros.begin(); it != macros.end(); ++it)
delete it->second; delete it->second;
macros.clear();
return ""; return "";
} }
@ -2628,7 +2628,7 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file
std::map<std::string, PreprocessorMacro *>::iterator iter; std::map<std::string, PreprocessorMacro *>::iterator iter;
for (iter = macros.begin(); iter != macros.end(); ++iter) for (iter = macros.begin(); iter != macros.end(); ++iter)
delete iter->second; delete iter->second;
macros.clear();
return ""; return "";
} }
@ -2681,6 +2681,7 @@ std::string Preprocessor::expandMacros(const std::string &code, std::string file
for (std::map<std::string, PreprocessorMacro *>::iterator it = macros.begin(); it != macros.end(); ++it) for (std::map<std::string, PreprocessorMacro *>::iterator it = macros.begin(); it != macros.end(); ++it)
delete it->second; delete it->second;
macros.clear();
return ostr.str(); return ostr.str();
} }