Add preprocessing for FreeBSD

FreeBSD uses stdlib.h instead of malloc.h.