diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index b67526d3f..19d325592 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -41,10 +41,12 @@ CheckMemoryLeakStructMember instance3; CheckMemoryLeakNoVar instance4; } - -// This list needs to be alphabetically sorted so we can run bsearch on it. -// 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 +/** List of functions that can be ignored when searching for memory leaks. + * These functions don't take the address of the given pointer + * This list needs to be alphabetically sorted so we can run bsearch on it. + * 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[] = { "_open", "_wopen", "access", "adjtime", "asctime", "asctime_r", "asprintf", "assert" diff --git a/lib/checkmemoryleak.h b/lib/checkmemoryleak.h index e23090439..6cda1b099 100644 --- a/lib/checkmemoryleak.h +++ b/lib/checkmemoryleak.h @@ -28,7 +28,7 @@ * * %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. * - CheckMemoryLeakInClass can detect when a class variable is allocated but not deallocated properly. * - CheckMemoryLeakStructMember checks allocation/deallocation of structs and struct members @@ -124,12 +124,24 @@ public: /** * @brief Is a typename the name of a class? * @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 */ 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); + + /** + * 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); /**