Updated so includes cast to char for malloc

Also added free for memory