GRASS Programmer's Manual
6.4.2(2012)
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
alloc_cell.c
Go to the documentation of this file.
1
17
#include <math.h>
18
#include <grass/gis.h>
19
20
/* convert type "RASTER_MAP_TYPE" into index */
21
#define F2I(map_type) \
22
(map_type == CELL_TYPE ? 0 : (map_type == FCELL_TYPE ? 1 : 2))
23
24
static
int
type_size[3] = {
sizeof
(CELL),
sizeof
(FCELL),
sizeof
(DCELL) };
25
26
38
size_t
G_raster_size
(RASTER_MAP_TYPE data_type)
39
{
40
return
(type_size[
F2I
(data_type)]);
41
}
42
43
64
CELL *
G_allocate_cell_buf
(
void
)
65
{
66
return
(CELL *) G_calloc(
G_window_cols
() + 1,
sizeof
(CELL));
67
}
68
69
81
void
*
G_allocate_raster_buf
(RASTER_MAP_TYPE data_type)
82
{
83
return
(
void
*)G_calloc(
G_window_cols
() + 1,
G_raster_size
(data_type));
84
}
85
86
96
CELL *
G_allocate_c_raster_buf
(
void
)
97
{
98
return
(CELL *) G_calloc(
G_window_cols
() + 1,
sizeof
(CELL));
99
}
100
101
111
FCELL *
G_allocate_f_raster_buf
(
void
)
112
{
113
return
(FCELL *) G_calloc(
G_window_cols
() + 1,
sizeof
(FCELL));
114
}
115
116
126
DCELL *
G_allocate_d_raster_buf
(
void
)
127
{
128
return
(DCELL *) G_calloc(
G_window_cols
() + 1,
sizeof
(DCELL));
129
}
130
131
141
char
*
G_allocate_null_buf
(
void
)
142
{
143
return
(
char
*)G_calloc(
G_window_cols
() + 1,
sizeof
(
char
));
144
}
145
146
156
unsigned
char
*
G__allocate_null_bits
(
int
cols
)
157
{
158
return
(
unsigned
char
*)G_calloc(
G__null_bitstream_size
(cols) + 1,
159
sizeof
(
unsigned
char
));
160
}
161
162
171
int
G__null_bitstream_size
(
int
cols
)
172
{
173
if
(cols <= 0)
174
return
-1;
175
176
return
(cols / 8 + (cols % 8 != 0));
177
}
lib
gis
alloc_cell.c
Generated on Sun Mar 16 2014 05:07:42 for GRASS Programmer's Manual by
1.8.1.2