memory leaks: simple code cleanup
This commit is contained in:
parent
5dd7b054f9
commit
14fd0154d2
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue