GRASS 8 Programmer's Manual 8.6.0dev(2026)-ddeab64dbf
Loading...
Searching...
No Matches
alloc_cell.c File Reference

Raster Library - Raster allocation routines. More...

#include <math.h>
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/glocale.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 Rast_cell_size (RASTER_MAP_TYPE data_type)
 Returns size of a raster cell in bytes.
 
voidRast_allocate_buf (RASTER_MAP_TYPE data_type)
 Allocate memory for a raster map of given type.
 
CELLRast_allocate_c_buf (void)
 Allocate memory for a CELL type raster map.
 
FCELLRast_allocate_f_buf (void)
 Allocates memory for a raster map of type FCELL.
 
DCELLRast_allocate_d_buf (void)
 Allocates memory for a raster map of type DCELL.
 
charRast_allocate_null_buf (void)
 Allocates memory for a null buffer.
 
unsigned charRast__allocate_null_bits (int cols)
 Allocates memory for null bits.
 
int Rast__null_bitstream_size (int cols)
 Determines null bitstream size.
 
voidRast_allocate_input_buf (RASTER_MAP_TYPE data_type)
 
CELLRast_allocate_c_input_buf (void)
 
FCELLRast_allocate_f_input_buf (void)
 
DCELLRast_allocate_d_input_buf (void)
 
charRast_allocate_null_input_buf (void)
 
voidRast_allocate_output_buf (RASTER_MAP_TYPE data_type)
 
CELLRast_allocate_c_output_buf (void)
 
FCELLRast_allocate_f_output_buf (void)
 
DCELLRast_allocate_d_output_buf (void)
 
charRast_allocate_null_output_buf (void)
 

Detailed Description

Raster Library - Raster allocation routines.

(C) 2001-2009 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
Original author CERL

Definition in file alloc_cell.c.

Macro Definition Documentation

◆ F2I

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

Definition at line 21 of file alloc_cell.c.

Function Documentation

◆ Rast__allocate_null_bits()

unsigned char * Rast__allocate_null_bits ( int  cols)

Allocates memory for null bits.

Allocates an array of unsigned char based on cols.

Parameters
colsnumber of columns in region
Returns
pointer to allocated buffer

Definition at line 133 of file alloc_cell.c.

References G_calloc, and Rast__null_bitstream_size().

Referenced by Rast__open_null_write(), and Rast__open_old().

◆ Rast__null_bitstream_size()

int Rast__null_bitstream_size ( int  cols)

Determines null bitstream size.

Parameters
colsnumber of columns
Returns
size of null bitstream

Definition at line 146 of file alloc_cell.c.

References _, and G_fatal_error().

Referenced by G__set_flags_from_01_random(), Rast__allocate_null_bits(), Rast__convert_01_flags(), Rast__convert_flags_01(), Rast__init_null_bits(), Rast__read_null_bits(), and Rast__write_null_bits().

◆ Rast_allocate_buf()

void * Rast_allocate_buf ( RASTER_MAP_TYPE  data_type)

Allocate memory for a raster map of given type.

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

Parameters
data_typeraster type (CELL, FCELL, DCELL)
Returns
pointer to allocated buffer

Definition at line 53 of file alloc_cell.c.

References G_calloc, Rast_cell_size(), and Rast_window_cols().

Referenced by N_read_rast_to_array_2d(), N_write_array_2d_to_rast(), and P_Aux_to_Raster().

◆ Rast_allocate_c_buf()

CELL * Rast_allocate_c_buf ( void  )

Allocate memory for a CELL type raster map.

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

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 * Rast_allocate_c_buf(void)
Allocate memory for a CELL type raster map.
Definition alloc_cell.c:80
int CELL
Definition gis.h:634

If larger buffers are required, the routine G_malloc() can be used. The routine is generally used with each open cell file.

Prints error message and calls exit() on error.

Returns
pointer to allocated buffer

Definition at line 80 of file alloc_cell.c.

References G_calloc, and Rast_window_cols().

Referenced by create_raster(), Gs_get_cat_label(), I_compute_scatts(), IL_create_bitmask(), open_band_files(), and Rast_map_to_img_str().

◆ Rast_allocate_c_input_buf()

CELL * Rast_allocate_c_input_buf ( void  )

Definition at line 160 of file alloc_cell.c.

References G_calloc, and Rast_input_window_cols().

◆ Rast_allocate_c_output_buf()

CELL * Rast_allocate_c_output_buf ( void  )

Definition at line 185 of file alloc_cell.c.

References G_calloc, and Rast_output_window_cols().

◆ Rast_allocate_d_buf()

DCELL * Rast_allocate_d_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
pointer to allocated buffer

Definition at line 106 of file alloc_cell.c.

References G_calloc, and Rast_window_cols().

Referenced by Gs_get_cat_label(), Rast_get_sample_bilinear(), Rast_get_sample_cubic(), Rast_get_sample_nearest(), and Rast_map_to_img_str().

◆ Rast_allocate_d_input_buf()

DCELL * Rast_allocate_d_input_buf ( void  )

Definition at line 170 of file alloc_cell.c.

References G_calloc, and Rast_input_window_cols().

◆ Rast_allocate_d_output_buf()

DCELL * Rast_allocate_d_output_buf ( void  )

Definition at line 195 of file alloc_cell.c.

References G_calloc, and Rast_output_window_cols().

◆ Rast_allocate_f_buf()

FCELL * Rast_allocate_f_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
pointer to allocated buffer

Definition at line 93 of file alloc_cell.c.

References G_calloc, and Rast_window_cols().

Referenced by IL_output_2d(), and Rast_map_to_img_str().

◆ Rast_allocate_f_input_buf()

FCELL * Rast_allocate_f_input_buf ( void  )

Definition at line 165 of file alloc_cell.c.

References G_calloc, and Rast_input_window_cols().

◆ Rast_allocate_f_output_buf()

FCELL * Rast_allocate_f_output_buf ( void  )

Definition at line 190 of file alloc_cell.c.

References G_calloc, and Rast_output_window_cols().

Referenced by IL_resample_output_2d().

◆ Rast_allocate_input_buf()

void * Rast_allocate_input_buf ( RASTER_MAP_TYPE  data_type)

Definition at line 155 of file alloc_cell.c.

References G_calloc, Rast_cell_size(), and Rast_input_window_cols().

Referenced by Rast_get_vrt_row().

◆ Rast_allocate_null_buf()

char * Rast_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
pointer to allocated buffer

Definition at line 119 of file alloc_cell.c.

References G_calloc, and Rast_window_cols().

Referenced by I_compute_scatts(), and I_insert_patch_to_cat_rast().

◆ Rast_allocate_null_input_buf()

char * Rast_allocate_null_input_buf ( void  )

Definition at line 175 of file alloc_cell.c.

References G_calloc, and Rast_input_window_cols().

◆ Rast_allocate_null_output_buf()

char * Rast_allocate_null_output_buf ( void  )

Definition at line 200 of file alloc_cell.c.

References G_calloc, and Rast_output_window_cols().

◆ Rast_allocate_output_buf()

void * Rast_allocate_output_buf ( RASTER_MAP_TYPE  data_type)

Definition at line 180 of file alloc_cell.c.

References G_calloc, Rast_cell_size(), and Rast_output_window_cols().

◆ Rast_cell_size()

size_t Rast_cell_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
data_typeraster type (CELL, FCELL, DCELL)
Returns
raster type size

Definition at line 37 of file alloc_cell.c.

References F2I.

Referenced by D_draw_raster_RGB(), f_median(), f_nmedian(), N_read_rast_to_array_2d(), P_Aux_to_Raster(), Rast__lookup_colors(), Rast__set_null_value(), Rast_allocate_buf(), Rast_allocate_input_buf(), Rast_allocate_output_buf(), Rast_get_row_colors(), Rast_get_vrt_row(), Rast_mark_cats(), Rast_raster_cpy(), Rast_row_update_fp_range(), Rast_zero_buf(), Rast_zero_input_buf(), and Rast_zero_output_buf().