Once you've written a file malloc.c containing the malloc, free, calloc, and realloc functions, you can test it in a couple of ways:
gcc malloc.c churn.c -o churnwill compile the churn program so that it uses the malloc functions in malloc.c
gcc -shared -fPIC malloc.c -o malloc.soand then tell the system to use your malloc with
export LD_PRELOAD=./malloc.so(or better, give the full path to malloc.so so things work outside of your malloc directory).
export LD_PRELOAD=to turn it off.