updated comments

This commit is contained in:
Daniel Marjamäki 2011-09-08 18:23:25 +02:00
parent 074ad10a30
commit 184e0550b8
2 changed files with 20 additions and 6 deletions

View File

@ -41,10 +41,12 @@ CheckMemoryLeakStructMember instance3;
CheckMemoryLeakNoVar instance4; CheckMemoryLeakNoVar instance4;
} }
/** List of functions that can be ignored when searching for memory leaks.
// This list needs to be alphabetically sorted so we can run bsearch on it. * These functions don't take the address of the given pointer
// This list contains function names whith const parameters e.g.: atof(const char *) * This list needs to be alphabetically sorted so we can run bsearch on it.
// Reference: http://www.aquaphoenix.com/ref/gnu_c_library/libc_492.html#SEC492 * This list contains function names whith const parameters e.g.: atof(const char *)
* Reference: http://www.aquaphoenix.com/ref/gnu_c_library/libc_492.html#SEC492
*/
static const char * const call_func_white_list[] = static const char * const call_func_white_list[] =
{ {
"_open", "_wopen", "access", "adjtime", "asctime", "asctime_r", "asprintf", "assert" "_open", "_wopen", "access", "adjtime", "asctime", "asctime_r", "asprintf", "assert"

View File

@ -28,7 +28,7 @@
* *
* %Check for memory leaks * %Check for memory leaks
* *
* The checking is split up into two specialized classes. * The checking is split up into three specialized classes.
* - CheckMemoryLeakInFunction can detect when a function variable is allocated but not deallocated properly. * - CheckMemoryLeakInFunction can detect when a function variable is allocated but not deallocated properly.
* - CheckMemoryLeakInClass can detect when a class variable is allocated but not deallocated properly. * - CheckMemoryLeakInClass can detect when a class variable is allocated but not deallocated properly.
* - CheckMemoryLeakStructMember checks allocation/deallocation of structs and struct members * - CheckMemoryLeakStructMember checks allocation/deallocation of structs and struct members
@ -124,12 +124,24 @@ public:
/** /**
* @brief Is a typename the name of a class? * @brief Is a typename the name of a class?
* @param _tokenizer tokenizer * @param _tokenizer tokenizer
* @param typestr type name * @param tok type token
* @param varid variable id
* @return true if the type name is the name of a class * @return true if the type name is the name of a class
*/ */
bool isclass(const Tokenizer *_tokenizer, const Token *typestr, unsigned int varid) const; bool isclass(const Tokenizer *_tokenizer, const Token *typestr, unsigned int varid) const;
/**
* Report that there is a memory leak (new/malloc/etc)
* @param tok token where memory is leaked
* @param varname name of variable
*/
void memleakError(const Token *tok, const std::string &varname); void memleakError(const Token *tok, const std::string &varname);
/**
* Report that there is a resource leak (fopen/popen/etc)
* @param tok token where resource is leaked
* @param varname name of variable
*/
void resourceLeakError(const Token *tok, const std::string &varname); void resourceLeakError(const Token *tok, const std::string &varname);
/** /**