Wrapper functions on malloc, free
Memory leak is a challenge that awaits any developer working in c. There are many tools, which perform both static and dynamic (run-time) analysis of the source code. These tools report memory leaks, if any. Klocwork is one such tool that can do. However, these are tools which require license fees. There are quite a few open-source projects which basically wraps all calls to malloc and free to custom functions. These functions monitor the usage of memory and finally call the actual memory allocation/deallocation routines. [Code] #include int main() { int *ptr = (int*)malloc(sizeof(int)*32); return(0); } Few tools have a macro, #define malloc custom_malloc #define free custom_free It is this custom_malloc, which gets invoked, void* custom_malloc(size_t size) { // Update report with the requested size return(malloc(size)); } And once the program is executed, the developer gets a chance to have a look at the report (stored in a file) along with other details like line number ...