redefining malloc() is evil
Especially when it's in an external library, like say, perl. It's a recipe for heap corruption when pointers allocated by the real malloc are passed to the redefined free and vice versa. Nasty. Whats worse is when that library redefines malloc(), free(), calloc() and realloc(), but leaves strdup() alone.
Guess how long it took to track that one down on windows, where valgrind is sorely missed? Too long, that's how long.
How did we live without valgrind!?