title: free 2d array in c
body: <p>I was solving some simple pointer exercises when i came across the following example:</p>
  
  <pre><code>void deallocate2D(int** array, int nrows) {     
   /*  deallocate each row  */
   int i;
   for(i = 0; i &lt; nrows; i++) {
        free(array[i]);
   }
  
   /*  deallocate array of pointers  */
   free(array);     
  }
  </code></pre>
  
  <p>The array is defined in main as int** array1;</p>
  
  <p>Is this a correct way of deallocating memory of a 2d array or should an int*** array be passed in the function instead?
  Is there a way to check that memory has been successfully deallocated?</p>