I am dealing with some legacy C/C++ code where memory is allocated using malloc as well as using new. I want to create a generalized wrapper function to deallocate the memory using either free or delete [] , depending on how it is allocated.
Is there a way to determine how memory is allocated ? Here is a pseudo code.
double *x;
double *y;
x = (double *) malloc(size);
y = new double [size]
doSomething();
deallocateMemory(x, y);
I want deallocateMemory to determine whether to call free or delete [] . Any help would be appreciated.
