I have been looking into custom allocators and I quite often see them using some kind of function to allocate memory. For testing purposes and further educate my self, I tri
With a placement new you can pass an already allocated memory location to the new operator. Then new will construct the object at the given place without doing an allocation on itself.
Edit:
This is how it could be implemented:
int main(void){
// get memory
void * mem_t = SomeAllocationFunction(sizeof(SomeClass));
// construct instance
SomeClass* t = new(mem_t) SomeClass;
// more code
// clean up instance
t->~SomeClass();
return 0;
}