xxxxxxxxxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int** allocate2D(int** A, const int N, const int M) {
int i;
int *t0;
A = malloc(M * sizeof (int*)); /* Allocating pointers */
t0 = malloc(N * M * sizeof (int)); /* Allocating data */
for (i = 0; i < M; i++)
A[i] = t0 + i * (N);
return A;
}
void free2Darray(int** p) {
free(p[0]);
free(p);
}