GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
alloc_cell.c File Reference

GIS Library - Raster allocation routines. More...

#include <math.h>
#include <grass/gis.h>
Include dependency graph for alloc_cell.c:

Go to the source code of this file.

Macros

#define F2I(map_type)   (map_type == CELL_TYPE ? 0 : (map_type == FCELL_TYPE ? 1 : 2))
 

Functions

size_t G_raster_size (RASTER_MAP_TYPE data_type)
 Returns size of a raster CELL in bytes. More...
 
CELL * G_allocate_cell_buf (void)
 Allocate memory for a CELL type raster map. More...
 
void * G_allocate_raster_buf (RASTER_MAP_TYPE data_type)
 Allocate memory for a raster map of type data_type. More...
 
CELL * G_allocate_c_raster_buf (void)
 Allocates memory for a raster map of type CELL. More...
 
FCELL * G_allocate_f_raster_buf (void)
 Allocates memory for a raster map of type FCELL. More...
 
DCELL * G_allocate_d_raster_buf (void)
 Allocates memory for a raster map of type DCELL. More...
 
char * G_allocate_null_buf (void)
 Allocates memory for a null buffer. More...
 
unsigned char * G__allocate_null_bits (int cols)
 Allocates memory for null bits. More...
 
int G__null_bitstream_size (int cols)
 Determines null bitstream size. More...
 

Detailed Description

GIS Library - Raster allocation routines.

(C) 2001-2008 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
GRASS GIS Development Team
Date
1999-2008

Definition in file alloc_cell.c.

Macro Definition Documentation

#define F2I (   map_type)    (map_type == CELL_TYPE ? 0 : (map_type == FCELL_TYPE ? 1 : 2))

Definition at line 21 of file alloc_cell.c.

Referenced by G_raster_size().

Function Documentation

unsigned char* G__allocate_null_bits ( int  cols)

Allocates memory for null bits.

Allocates an array of unsigned char based on cols.

Parameters
[in]colsnumber of columns in region
Returns
unsigned char *

Definition at line 156 of file alloc_cell.c.

References G__null_bitstream_size().

Referenced by G__open_cell_old().

int G__null_bitstream_size ( int  cols)

Determines null bitstream size.

Parameters
[in]colsnumber of columns
Returns
-1 if cols is invalid (<= 0)
size of null bistream

Definition at line 171 of file alloc_cell.c.

Referenced by G__allocate_null_bits(), G__check_null_bit(), G__convert_01_flags(), G__convert_flags_01(), G__init_null_bits(), G__set_flags_from_01_random(), and G__write_null_bits().

CELL* G_allocate_c_raster_buf ( void  )

Allocates memory for a raster map of type CELL.

Allocate an array of CELL based on the number of columns in the current region.

Returns
CELL *

Definition at line 96 of file alloc_cell.c.

References G_window_cols().

Referenced by G_get_null_value_row(), and Gs_get_cat_label().

CELL* G_allocate_cell_buf ( void  )

Allocate memory for a CELL type raster map.

This routine allocates a buffer of type CELL just large enough to hold one row of raster data based on the number of columns in the active region.

CELL *cell;

If larger buffers are required, the routine G_malloc can be used. The routine is generally used with each open cell file.
Note: G_allocate_raster_buf() or G_alloc_c_raster_buf() is preferred over G_allocate_cell_buf().

Returns
CELL * Pointer to allocated buffer
Prints error message and calls exit() on error

Definition at line 64 of file alloc_cell.c.

References G_window_cols().

Referenced by IL_create_bitmask().

DCELL* G_allocate_d_raster_buf ( void  )

Allocates memory for a raster map of type DCELL.

Allocate an array of DCELL based on the number of columns in the current region.

Returns
DCELL *

Definition at line 126 of file alloc_cell.c.

References G_window_cols().

Referenced by G_get_raster_sample_bilinear(), G_get_raster_sample_cubic(), G_get_raster_sample_nearest(), and Gs_get_cat_label().

FCELL* G_allocate_f_raster_buf ( void  )

Allocates memory for a raster map of type FCELL.

Allocate an array of FCELL based on the number of columns in the current region.

Returns
FCELL *

Definition at line 111 of file alloc_cell.c.

References G_window_cols().

Referenced by IL_output_2d(), and IL_resample_output_2d().

char* G_allocate_null_buf ( void  )

Allocates memory for a null buffer.

Allocate an array of char based on the number of columns in the current region.

Returns
char *

Definition at line 141 of file alloc_cell.c.

References G_window_cols().

Referenced by Gs_loadmap_as_bitmap(), Gs_loadmap_as_char(), Gs_loadmap_as_float(), Gs_loadmap_as_int(), and Gs_loadmap_as_short().

void* G_allocate_raster_buf ( RASTER_MAP_TYPE  data_type)

Allocate memory for a raster map of type data_type.

Allocate an array of CELL, FCELL, or DCELL (depending on data_type) based on the number of columns in the current region.

Parameters
[in]data_type
Returns
void *

Definition at line 81 of file alloc_cell.c.

References G_raster_size(), and G_window_cols().

Referenced by N_read_rast_to_array_2d(), and N_write_array_2d_to_rast().

size_t G_raster_size ( RASTER_MAP_TYPE  data_type)

Returns size of a raster CELL in bytes.

If data_type is CELL_TYPE, returns sizeof(CELL) If data_type is FCELL_TYPE, returns sizeof(FCELL) If data_type is DCELL_TYPE, returns sizeof(DCELL)

Parameters
[in]data_type
Returns
int

Definition at line 38 of file alloc_cell.c.

References F2I.

Referenced by D_draw_raster_RGB(), G__lookup_colors(), G__set_null_value(), G_allocate_raster_buf(), G_get_raster_row_colors(), G_mark_raster_cats(), G_raster_cpy(), G_row_update_fp_range(), G_zero_raster_buf(), and N_read_rast_to_array_2d().