Replace malloc.h with stdlib.h
Fix an error in the build if check is not present on the system