These warnings:
warning: initialization makes pointer from integer without a cast
warning: assignment makes pointer from integer without a cast
...for a line containing malloc could mean that you forgot to #include "stdlib.h".
Functions are assumed to return an integer type by default if not declared.