Changed the malloc call to new call to fit C++