Reputation: 5191
I am writing an open-source tool for run-time memory issue debugging:
https://github.com/sandeepsinghmails/S_malloc
The current version requires the user to change his/her wrapper functions for malloc()
and free()
and call two additional functions from my library.
I want to modify this code so that the user's malloc()
and free()
calls are automatically mapped to my own implementations. The user need not modify his source code (something which Valgrind provides).
Can somebody please guide me on this?
Upvotes: 0
Views: 202
Reputation: 496
Take a look at malloc_hooks:
http://man7.org/linux/man-pages/man3/malloc_hook.3.html
The GNU C library lets you modify the behavior of malloc(3), realloc(3), and free(3) by specifying appropriate hook functions. You can use these hooks to help you debug programs that use dynamic memory allocation, for example.
Upvotes: 3