修改编译参数

OSX 10.5+以——10.11,MAC把malloc.h放在 /usr/include/malloc中 编译的时候

makefile中添加编译选项

CFLAGS=-I/usr/include/malloc

编译前修改系统变量

export CFLAGS=-I/usr/include/malloc

用sys/malloc.h替换malloc.h

#include <sys/malloc.h>

放弃malloc.h,使用标准stdlib.h

stdlib.h is a standard C header that declares among other things the malloc(), calloc(), free() functions. This is the header you should include.

malloc.h is a non-standard header, found on many systems where it often defines additional functions specific to the malloc implementation used by that platform.
It works on my mac.