alloc_cell.c

Go to the documentation of this file.
00001 #include <math.h>
00002 #include "gis.h"
00003 
00004 /* convert type "RASTER_MAP_TYPE" into index */
00005 #define F2I(map_type) \
00006         (map_type == CELL_TYPE ? 0 : (map_type == FCELL_TYPE ? 1 : 2))
00007 
00008 static int type_size[3] = {sizeof(CELL), sizeof(FCELL), sizeof(DCELL)};
00009 
00010 
00022 int G_raster_size (data_type)
00023     RASTER_MAP_TYPE data_type;
00024 {
00025     return (type_size[F2I(data_type)]);
00026 }
00027 
00028 
00047 CELL *
00048 G_allocate_cell_buf ()
00049 {
00050     return (CELL *) G_calloc (G_window_cols() + 1, sizeof(CELL));
00051 }
00052 
00062 void *
00063 G_allocate_raster_buf (data_type)
00064 RASTER_MAP_TYPE data_type;
00065 {
00066     return (void *) G_calloc (G_window_cols() + 1, G_raster_size(data_type));
00067 }
00068 
00078 CELL *
00079 G_allocate_c_raster_buf ()
00080 {
00081     return (CELL *) G_calloc (G_window_cols() + 1, sizeof(CELL));
00082 }
00083 
00093 FCELL *
00094 G_allocate_f_raster_buf ()
00095 {
00096     return (FCELL *) G_calloc (G_window_cols() + 1, sizeof(FCELL));
00097 }
00098 
00108 DCELL *
00109 G_allocate_d_raster_buf ()
00110 {
00111     return (DCELL *) G_calloc (G_window_cols() + 1, sizeof(DCELL));
00112 }
00113 
00123 char *
00124 G_allocate_null_buf ()
00125 {
00126     return (char *) G_calloc (G_window_cols() + 1, sizeof(char));
00127 }
00128 
00129 unsigned char *
00130 G__allocate_null_bits (cols)
00131    int cols;
00132 {
00133     return (unsigned char *) G_calloc (G__null_bitstream_size(cols)+1, 
00134                                sizeof(unsigned char));
00135 }
00136 
00137 int
00138 G__null_bitstream_size(cols)
00139   int cols;
00140 {
00141   if (cols <= 0 ) return -1;
00142   return (cols/8 + (cols % 8 != 0));
00143 }

Generated on Sat Jul 22 22:06:14 2006 for GRASS by  doxygen 1.4.7