blob: e21215b7205e9a97905ea2a7387806d4c66b2e37 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/*
* === FUNCTION ======================================================================
* Name: calloc_int_matrix
* Description: Allocate a dynamic int-matrix of size rows*columns; return a pointer.
* =====================================================================================
*/
int**
calloc_int_matrix ( int rows, int columns )
{
int i;
int **m;
m = calloc ( rows, sizeof(int*) ); /* allocate pointer array */
assert( m != NULL ); /* abort if allocation failed */
*m = calloc ( rows*columns, sizeof(int) ); /* allocate data array */
assert(*m != NULL ); /* abort if allocation failed */
for ( i=1; i<rows; i+=1 ) /* set pointers */
m[i] = m[i-1] + columns;
return m;
} /* ---------- end of function calloc_int_matrix ---------- */
/*
* === FUNCTION ======================================================================
* Name: free_int_matrix
* Description: Free a dynamic int-matrix.
* =====================================================================================
*/
void
free_int_matrix ( int **m )
{
free(*m); /* free data array */
free( m); /* free pointer array */
return ;
} /* ---------- end of function free_int_matrix ---------- */
|