I made a general memory manager that takes the size of any datatype and allocs a char * to that size. When alloc() is called it returns void * which is then needed to be casted into the desired type.
However, this breaks when it is called on any object that is a derived class because the vtable is all screwy. Any suggestions?
example:
int *a = reinterpret_cast< int *>(alloc());
It's because the constructors are never called and thus the vtables are never set up. This won't work for any class containing at least one virtual method.
The difference between malloc and new is new calls constructors, malloc doesn't. You've written a replacement for malloc and are expecting to be able to construct objects using malloc, and you can't.
Larger projects either use lots of static allocation, or are really careful with their dynamic allocation.
If you find a bug which you suspect comes from poor dynamic memory management, you can use a memory debugger to try and find it.