I cannot put my finger on why my program hangs and crashes when I pass my 2d-array, declared on the heap, between functions which accept double pointers.

I am getting a strong feeling that it has to do with the method I have chosen to declare the 2d array. Before I created a function to allocate the array, the program could manipulate the data inside the array when passed to a function.

So here is the allocate function and then the function which it crashes inside:

```
void matrix_malloc(int **matrix, int m, int n);
void matrix_init(int **matrix, int m, int n);

int main(void)
{
  int **matrix;
  int m(3), n(2);

  matrix_malloc(matrix, m, n);
  matrix_init(matrix, m, n); // runtime error
}

void matrix_malloc(int **matrix, int m, int n)
{ // get heap memory
  int i;
  matrix = new int*[m];
  for(i = 0; i < m; i++)
  {
    matrix[i] = new int[n];
  }
}

void matrix_init(int **matrix, int m, int n)
{ // randomize matrix
  int i, j;
  for(i = 0; i < m; i++)
  {
    for(j = 0; j < n; j++)
    {
      matrix[i][j] = rand() % 10 + 1;
    }
  }
}

```