title: passing a triple pointer into function then mallocing a 2d array
body: <p>Getting a segmentation fault and don't understand why, have to pass in triple pointer for assignment so can't change that...</p>
  
  <p>Here's the function</p>
  
  <pre><code>    void alloc2d(double*** a, int m, int n) {
       int i, j;
  
       **a  = malloc(sizeof(double *) * m);
       a[0] = malloc(sizeof(double) * n * m);
  
       for(i = 0; i &lt; m; i++)
        a[i] = (*a + n * i);
      }
  </code></pre>
  
  <p>Here's the calling of the function...</p>
  
  <pre><code>double** m;
  alloc2d(&amp;m, 5, 10);
  
  double count = 0.0;
  
  for (int i = 0; i &lt; 5; i++)
      for (int j = 0; j &lt; 10; j++)
          m[i][j] = ++count;
  
  for (int i = 0; i &lt;  5; i++)
      for (int j = 0; j &lt; 10; j++)
          printf("%f ", m[i][j]);
  </code></pre>