Possible Duplicate:
What is the best solution to replace a new memory allocator in an existing code?
I'm writing a library in C.  I'd like to know if there is a way to divert every malloc() call my library makes to a different "augmented" testmalloc() function that I provide without (significantly) modifying my library.  This question is inspired from p158 of Kernighan and Pike's "The Practice of Programming", where they say
Write a version of your storage allocator that intentionally fails early, to test your code for recovering from out-of-memory errors.
I am in a position where I could provide a wrapper mymalloc() and use that exclusively in my library.  I suspect it will be necessary to use this freedom to avoid multiple symbol definitions during linking.