GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ialloc.c
Go to the documentation of this file.
1 
27 #include <stdlib.h>
28 #include <grass/gis.h>
29 
30 
41 int *G_alloc_ivector(size_t n)
42 {
43  return (int *)G_calloc(n, sizeof(int));
44 }
45 
58 int **G_alloc_imatrix(int rows, int cols)
59 {
60  int **m;
61  int i;
62 
63  m = (int **)G_calloc(rows, sizeof(int *));
64  m[0] = (int *)G_calloc(rows * cols, sizeof(int));
65  for (i = 1; i < rows; i++)
66  m[i] = m[i - 1] + cols;
67 
68  return m;
69 }
70 
81 void G_free_ivector(int *v)
82 {
83  G_free(v);
84  v = NULL;
85 
86  return;
87 }
88 
99 void G_free_imatrix(int **m)
100 {
101  G_free(m[0]);
102  G_free(m);
103  m = NULL;
104 
105  return;
106 }
void G_free(void *buf)
Free allocated memory.
Definition: gis/alloc.c:142
return NULL
Definition: dbfopen.c:1394
tuple cols
int * G_alloc_ivector(size_t n)
Vector matrix memory allocation.
Definition: ialloc.c:41
int ** G_alloc_imatrix(int rows, int cols)
Matrix memory allocation.
Definition: ialloc.c:58
void G_free_imatrix(int **m)
Matrix memory deallocation.
Definition: ialloc.c:99
int n
Definition: dataquad.c:291
void G_free_ivector(int *v)
Definition: ialloc.c:81