diff --git a/CheckMemoryLeak.cpp b/CheckMemoryLeak.cpp index 532cfce8c..b58253270 100644 --- a/CheckMemoryLeak.cpp +++ b/CheckMemoryLeak.cpp @@ -189,9 +189,26 @@ CheckMemoryLeakClass::AllocType CheckMemoryLeakClass::GetDeallocationType( const //-------------------------------------------------------------------------- const char * CheckMemoryLeakClass::call_func( const TOKEN *tok, std::list callstack, const char *varnames[], AllocType &alloctype, AllocType &dealloctype ) -{ - if (TOKEN::Match(tok,"if") || TOKEN::Match(tok,"for") || TOKEN::Match(tok,"while")) +{ + // Keywords that are not function calls.. + if (TOKEN::Match(tok,"if|for|while")) + return 0; + + // String functions that are not allocating nor deallocating memory.. + if (TOKEN::Match(tok, "strcpy|strncpy|strcat|strncat|strcmp|strncmp|strcasecmp|stricmp|sprintf|strchr|strrchr|strstr")) + return 0; + + // Memory functions that are not allocating nor deallocating memory.. + if (TOKEN::Match(tok, "memset|memcpy|memmove|memchr")) + return 0; + + // I/O functions that are not allocating nor deallocating memory.. + if (TOKEN::Match(tok, "fgets|fgetc|fputs|fputc|printf")) return 0; + + // Convert functions that are not allocating nor deallocating memory.. + if (TOKEN::Match(tok, "atoi|atof|atol|strtol|strtoul|strtod")) + return 0; if (GetAllocationType(tok)!=No || GetReallocationType(tok)!=No || GetDeallocationType(tok,varnames)!=No) return 0;