GRASS Programmer's Manual
6.4.3(2013)-r
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
Pages
dalloc.c
Go to the documentation of this file.
1
26
#include <stdlib.h>
27
#include <grass/gis.h>
28
29
41
double
*
G_alloc_vector
(
size_t
n)
42
{
43
return
(
double
*)G_calloc(n,
sizeof
(
double
));
44
}
45
46
60
double
**
G_alloc_matrix
(
int
rows,
int
cols
)
61
{
62
double
**m;
63
int
i;
64
65
m = (
double
**)G_calloc(rows,
sizeof
(
double
*));
66
m[0] = (
double
*)G_calloc(rows * cols,
sizeof
(
double
));
67
for
(i = 1; i < rows; i++)
68
m[i] = m[i - 1] + cols;
69
70
return
m;
71
}
72
73
85
float
*
G_alloc_fvector
(
size_t
n)
86
{
87
return
(
float
*)G_calloc(n,
sizeof
(
float
));
88
}
89
90
104
float
**
G_alloc_fmatrix
(
int
rows,
int
cols
)
105
{
106
float
**m;
107
int
i;
108
109
m = (
float
**)G_calloc(rows,
sizeof
(
float
*));
110
m[0] = (
float
*)G_calloc(rows * cols,
sizeof
(
float
));
111
for
(i = 1; i < rows; i++)
112
m[i] = m[i - 1] + cols;
113
114
return
m;
115
}
116
117
129
void
G_free_vector
(
double
*v)
130
{
131
G_free
(v);
132
v =
NULL
;
133
134
return
;
135
}
136
137
149
void
G_free_fvector
(
float
*v)
150
{
151
G_free
(v);
152
v =
NULL
;
153
154
return
;
155
}
156
157
169
void
G_free_matrix
(
double
**m)
170
{
171
G_free
(m[0]);
172
G_free
(m);
173
m =
NULL
;
174
175
return
;
176
}
177
178
190
void
G_free_fmatrix
(
float
**m)
191
{
192
G_free
(m[0]);
193
G_free
(m);
194
m =
NULL
;
195
196
return
;
197
}
lib
gmath
dalloc.c
Generated on Thu Sep 26 2013 09:47:59 for GRASS Programmer's Manual by
1.8.4