I see in C++ there are multiple ways to allocate and free data and I understand that when you call malloc you should call free and when you use the
malloc
free
Always use new in C++. If you need a block of untyped memory, you can use operator new directly:
void *p = operator new(size); ... operator delete(p);