GRASS Programmer's Manual
6.4.2(2012)
|
00001 00027 #include <stdlib.h> 00028 #include <grass/gis.h> 00029 00030 00041 int *G_alloc_ivector(size_t n) 00042 { 00043 return (int *)G_calloc(n, sizeof(int)); 00044 } 00045 00058 int **G_alloc_imatrix(int rows, int cols) 00059 { 00060 int **m; 00061 int i; 00062 00063 m = (int **)G_calloc(rows, sizeof(int *)); 00064 m[0] = (int *)G_calloc(rows * cols, sizeof(int)); 00065 for (i = 1; i < rows; i++) 00066 m[i] = m[i - 1] + cols; 00067 00068 return m; 00069 } 00070 00081 void G_free_ivector(int *v) 00082 { 00083 G_free(v); 00084 v = NULL; 00085 00086 return; 00087 } 00088 00099 void G_free_imatrix(int **m) 00100 { 00101 G_free(m[0]); 00102 G_free(m); 00103 m = NULL; 00104 00105 return; 00106 }