As input, I use C ++ in Visual Studio 2010, compiling for x64. I have a program that uses 2-dimensional arrays to store data to execute a C-style function that I have no control with:
float **results;
results = new float*[rows];
for (int i = 0; i < rows; ++i){
results[i] = new float[columns];
}
int **data;
data = new int*[rows];
for (int i = 0; i < rows; ++i){
data[i] = new int[columns];
}
ExternalFunction(*data, *results);
for (int i = 0; i < rows-1; ++i){
delete [] &results[i];
delete [] &data[i];
}
delete [] results;
delete [] data;
This causes VS10 to fail with a Debug approval error with _BLOCK_TYPE_IS_VALID (pHead → nBlockUse). This happens at the end of the program, regardless of what actually happens in the last few lines containing these deletes. What does it mean? What am I doing wrong? I feel it is very simple, but I have looked at this code for too long.
- EDIT --- The problem has been resolved thanks to the dasblinkenlight useful jerk to my brain!
float *results = new float[rows * columns];
float *data = new float[rows * columns];
ExternalFunction(&data[0], &results[0]);
delete [] results;
delete [] data;
source
share