You likely forgot to #include <stdlib.h>
#include <stdlib.h>
You need to #include <stdlib.h>. Otherwise it's defined as int malloc() which is incompatible with the built-in type void *malloc(size_t).
int malloc()
void *malloc(size_t)
You're missing #include <stdlib.h>.