Defines | Functions

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.

Defines

#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.
CELL * G_allocate_cell_buf (void)
 Allocate memory for a CELL type raster map.
void * G_allocate_raster_buf (RASTER_MAP_TYPE data_type)
 Allocate memory for a raster map of type data_type.
CELL * G_allocate_c_raster_buf (void)
 Allocates memory for a raster map of type CELL.
FCELL * G_allocate_f_raster_buf (void)
 Allocates memory for a raster map of type FCELL.
DCELL * G_allocate_d_raster_buf (void)
 Allocates memory for a raster map of type DCELL.
char * G_allocate_null_buf (void)
 Allocates memory for a null buffer.
unsigned char * G__allocate_null_bits (int cols)
 Allocates memory for null bits.
int G__null_bitstream_size (int cols)
 Determines null bitstream size.

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.


Define 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().

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;
 cell = G_allocate_cell_buf ();

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().

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(), and G_get_raster_sample_nearest().

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().

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().

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().

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 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(), and G_zero_raster_buf().