Minor updates. Added todo. Refactoring

This commit is contained in:
Daniel Marjamäki 2008-04-12 12:07:35 +00:00
parent 4805f48a4f
commit 53f078fc1d
3 changed files with 13 additions and 4 deletions

View File

@ -464,9 +464,10 @@ void CheckMemset()
// Locate all 'memset' tokens..
for (const TOKEN *tok = tokens; tok; tok = tok->next)
{
if (strcmp(tok->str,"memset")!=0)
if (!Match(tok,"memset") && !Match(tok,"memcpy") && !Match(tok,"memmove"))
continue;
// Todo: Handle memcpy and memmove
const char *type = NULL;
if (Match(tok, "memset ( %var% , %num% , sizeof ( %type% ) )"))
type = getstr(tok, 8);

View File

@ -175,6 +175,15 @@ static void CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const char varname[]
if ( Match( tok, "[=,(] %var1% [,);]", varnames ) )
return;
// continue/break loop..
if (Alloc != No &&
alloc_indentlevel == indentlevel &&
(Match(tok,"continue") || Match(tok,"break")))
{
MemoryLeak( tok, varname );
return;
}
// Return without deallocating the memory..
if ( Alloc != No && alloc_indentlevel >= 0 && Match(tok, "return") )
{

View File

@ -472,7 +472,6 @@ static void memleak_in_function()
check( CheckMemoryLeak, __LINE__, test3, "" );
/* TODO
const char test4[] = "void f()\n"
"{\n"
" for (int i = 0; i < j; i++)\n"
@ -483,8 +482,8 @@ static void memleak_in_function()
" free(str);\n"
" }\n"
"}\n";
check( CheckMemoryLeak, __LINE__, test4, "[test.cpp:7]: Memory leak:str\n" );
*/
check( CheckMemoryLeak, __LINE__, test4, "[test.cpp:7]: Memory leak: str\n" );