I am looking for a tool to help me minimize the memory allocations inside a C project I'm currently porting.
Mainly, the following information would be useful:
1. line of code where memory zone was accessed
2. memory location
3. access mode (read/write)
Any form of parsing would be just a bonus, as well as the list of pointers to the indicated memory locations.
Dev tools: Visual C++ 2008 Express Edition
Do you know any software having these features?
Thanks.
For 1 and 2 you could just
void *log_malloc(const char *file, int line, const char *function, size_t size) {
void *mem = malloc(size);
/* log or do something with file, line, function, size and mem */
return mem;
}
#define malloc(size) log_malloc(__FILE__, __LINE__, __func__, size);
And the same for free, calloc, etc.