Memory leak : Changed the handling of "realloc" a little. The "getcode" will return "realloc" instead. And this will be converted to "dealloc;alloc;" before simplifycode

This commit is contained in:
Daniel Marjamäki 2009-01-01 18:42:32 +00:00
parent 35cdb6b0ba
commit ca550fb03e
1 changed files with 11 additions and 2 deletions

View File

@ -385,14 +385,16 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
if (TOKEN::Match(tok, "[(;{}] %var1% =", varnames)) if (TOKEN::Match(tok, "[(;{}] %var1% =", varnames))
{ {
AllocType alloc = GetAllocationType(tok->tokAt(3)); AllocType alloc = GetAllocationType(tok->tokAt(3));
bool realloc = false;
if ( alloc == No ) if ( alloc == No )
{ {
alloc = GetReallocationType( tok->tokAt(3) ); alloc = GetReallocationType( tok->tokAt(3) );
if ( alloc != No ) if ( alloc != No )
{ {
addtoken( "dealloc" ); addtoken( "realloc" );
addtoken( ";" ); addtoken( ";" );
realloc = true;
} }
} }
@ -408,6 +410,7 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list<const TOKEN *>
if ( alloc != No ) if ( alloc != No )
{ {
if ( ! realloc )
addtoken("alloc"); addtoken("alloc");
if (alloctype!=No && alloctype!=alloc) if (alloctype!=No && alloctype!=alloc)
MismatchError(tok, callstack, varname); MismatchError(tok, callstack, varname);
@ -1104,6 +1107,12 @@ void CheckMemoryLeakClass::CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const
tok2->str(";"); tok2->str(";");
else if (tok2->str() == "recursive" || tok2->str() == "dealloc_") else if (tok2->str() == "recursive" || tok2->str() == "dealloc_")
tok2->str("dealloc"); tok2->str("dealloc");
else if (tok2->str() == "realloc")
{
tok2->str("dealloc");
tok2->insertToken("alloc");
tok2->insertToken(";");
}
} }
simplifycode( tok ); simplifycode( tok );