What new does differently form malloc is the following:
- It constructs a value in the allocated memory, by calling
operator new. This behaviour can be adapted by overloading this operator, either for all types, or just for your class.
- It calls handler functions if no memory can be allocated. This gives you the opportunity to free the required memory on the fly if you have registered such a handler function beforehand.
- If that doesn't help (e.g. because you didn't register any function), it throws an exception.
So all in all, new is highly customizable and also does initialization work besides memory allocation. These are the two big differences.