title: 2-Dimensional array deallocation
body: <p>As an intro, I'm using C++ in Visual Studio 2010, compiling for x64. I have a program that's using 2-Dimensional arrays to store data for running through a C style function that I have no control over:</p>
  
  <pre><code>float **results;
  results = new float*[rows];
  for (int i = 0; i &lt; rows; ++i){
      results[i] = new float[columns];
  }
  
  int **data;
  data = new int*[rows];
  for (int i = 0; i &lt; rows; ++i){
      data[i] = new int[columns];
  }
  
  //send data to the function and populate results with values
  ExternalFunction(*data, *results);
  
  //delete everything
  for (int i = 0; i &lt; rows-1; ++i){
      delete [] &amp;results[i];
      delete [] &amp;data[i];
  }
  delete [] results;
  delete [] data;
  </code></pre>
  
  <p>This causes VS10 to through a Debug Assertion Failure with _BLOCK_TYPE_IS_VALID(pHead -> nBlockUse). This happens by the end of the program regardless of what really happens in the last few lines containing the deletes. What does this mean exactly? What am I doing wrong? I feel like it's really simple, but I've been looking at this code for too long.</p>
  
  <p>--EDIT---
  Problem solved thanks to dasblinkenlight's helpful nudge to my brain!</p>
  
  <pre><code>float *results = new float[rows * columns];
  float *data = new float[rows * columns];
  
  ExternalFunction(&amp;data[0], &amp;results[0]);
  
  delete [] results;
  delete [] data;
  </code></pre>