I've got a rather simple, though large, system setup. It stores it's data in a void*
array because the data it's storing could vary between float
or double
depending on how much accuracy is needed.
just doing delete [] data
raises a warning: deleting 'void*' is undefined [enabled by default]
using MinGW. And I've got another variable to tell me if data
is a float*
or a double*
, but does it matter which I use?
In other words, could I use the fallowing code without worrying about memory-leak's, or other errors/damage not caught by the compiler?
double* d_data = new double[length];
data = (void*)d_data;
delete [] (float*)data;