remove cast for malloc + add missing stdlib.h