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