title: Create a 3-D array with malloc but got RE and MLE
body: <p>I wrote a function with three parameter as height, width, and depth. After create a 3-D array with malloc, I return a <code>unsigned***</code> as array’s name.</p>
  
  <p>The other function is meant to delete this dynamic 3-D array. Using array’s name as parameter, and free it in the function.</p>
  
  <p>But I got some RE and MLE in the submit, I wonder where shouldn’t I do?</p>
  
  <pre class="lang-c prettyprint-override"><code>unsigned ***new_3d_array(unsigned n, unsigned m, unsigned k)
  {
      unsigned ***arr3D = (unsigned***)malloc(n * sizeof(unsigned**));
      int i, j;
  
      for (i = 0; i &lt; n; i++)
      {
          arr3D[i] =  (unsigned**)malloc(m * sizeof(unsigned*));
          for (j = 0; j &lt; m; j++)
          {
              arr3D[i][j] = (unsigned*)malloc(k * sizeof(unsigned));
          }
      }
  
      return arr3D;
  }
  void delete_3d_array(unsigned ***arr)
  {
      int i = 0, j = 0;
      while (arr[i] != NULL)
      {
          j = 0;
  
          while (arr[i][j] != NULL)
          {
              free(arr[i][j]);
              j++;
          }
          free(arr[i]);
          i++;
      }
      free(arr);
  }
  </code></pre>