From ca550fb03ed05d5c8ce70fe688975fc1db88143e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 1 Jan 2009 18:42:32 +0000 Subject: [PATCH] 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 --- checkmemoryleak.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/checkmemoryleak.cpp b/checkmemoryleak.cpp index bc3bff8a5..28fa33914 100644 --- a/checkmemoryleak.cpp +++ b/checkmemoryleak.cpp @@ -385,14 +385,16 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list 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,7 +410,8 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list if ( alloc != No ) { - addtoken("alloc"); + if ( ! realloc ) + addtoken("alloc"); if (alloctype!=No && alloctype!=alloc) MismatchError(tok, callstack, varname); if (dealloctype!=No && dealloctype!=alloc) @@ -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 );