memory leaks: simple code cleanup

This commit is contained in:
Daniel Marjamäki 2009-11-15 09:53:38 +01:00
parent 5dd7b054f9
commit 14fd0154d2
2 changed files with 10 additions and 21 deletions

View File

@ -427,6 +427,15 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::functionReturnType(const Token *tok)
void CheckMemoryLeakInFunction::parse_noreturn()
{
noreturn.insert("exit");
noreturn.insert("_exit");
noreturn.insert("_Exit");
noreturn.insert("abort");
noreturn.insert("err");
noreturn.insert("verr");
noreturn.insert("errx");
noreturn.insert("verrx");
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
{
if (tok->str() == "{")
@ -1053,27 +1062,6 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
else if (Token::Match(tok, "try|throw|catch"))
addtoken(tok->strAt(0));
// exit..
if (Token::Match(tok->previous(), "[{};] exit|_exit|_Exit ( %any% ) ;"))
{
addtoken("exit");
tok = tok->tokAt(3);
}
else if (Token::simpleMatch(tok, "abort ( ) ;"))
{
addtoken("exit");
tok = tok->tokAt(2);
}
else if (Token::Match(tok, "err|verr|errx|verrx ("))
{
addtoken("exit");
while (tok->next() && tok->next()->str() != ";")
{
tok = tok->next();
}
}
// Assignment..
if (varid)
{

View File

@ -290,6 +290,7 @@ private:
// getcode..
CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, 0, 0);
checkMemoryLeak.parse_noreturn();
std::list<const Token *> callstack;
callstack.push_back(0);
CheckMemoryLeak::AllocType allocType, deallocType;