alloc.c File Reference

#include <stdlib.h>
#include <grass/gis.h>

Include dependency graph for alloc.c:

Go to the source code of this file.

Functions

void * G_malloc (size_t n)
 memory allocation
void * G_calloc (size_t m, size_t n)
 memory allocation
void * G_realloc (void *buf, size_t n)
 memory allocation
void G_free (void *buf)
 free memory allocation


Function Documentation

void* G_calloc ( size_t  m,
size_t  n 
)

memory allocation

Allocates a properly aligned block of memory n*m bytes in length, initializes the allocated memory to zero, and returns a pointer to the allocated block of memory. Dies with error message on memory allocation fail. Note. Allocating memory for reading and writing raster files is discussed in Allocating_Raster_I_O_Buffers.

Parameters:
n number of elements
m element size
Returns:
void *

Definition at line 47 of file alloc.c.

References G_fatal_error(), and NULL.

Referenced by G__allocate_null_bits(), G__check_format(), G__open_cell_old(), G__quant_organize_fp_lookup(), G__read_Cell_head(), G_allocate_c_raster_buf(), G_allocate_cell_buf(), G_allocate_d_raster_buf(), G_allocate_f_raster_buf(), G_allocate_null_buf(), G_allocate_raster_buf(), G_asprintf(), G_available_mapsets(), G_list(), G_parser(), G_plot_area(), and G_recreate_command().

void G_free ( void *  buf  ) 

void* G_malloc ( size_t  n  ) 

memory allocation

Allocates a block of memory at least n bytes which is aligned properly for all data types. A pointer to the aligned block is returned. Dies with error message on memory allocation fail.

Parameters:
n 
Returns:
void *

Definition at line 17 of file alloc.c.

References G_fatal_error(), and NULL.

Referenced by G__location_path(), G__read_row_ptrs(), G__reallocate_mask_buf(), G__reallocate_null_buf(), G__reallocate_temp_buf(), G__reallocate_work_buf(), G__write_row_ptrs(), G_create_key_value(), G_define_flag(), G_define_option(), G_histogram_eq(), G_init_cell_stats(), G_is_reclassed_to(), G_list(), G_parser(), G_putenv(), G_set_d_raster_cat(), G_set_key_value(), G_sock_get_fname(), G_sort_cats(), G_store(), G_str_replace(), G_strdup(), G_tokenize(), G_version(), and test_path_file().

void* G_realloc ( void *  buf,
size_t  n 
)

memory allocation

Changes the size of a previously allocated block of memory at ptr and returns a pointer to the new block of memory. The size may be larger or smaller than the original size. If the original block cannot be extended "in place", then a new block is allocated and the original block copied to the new block. Note. If buf is NULL, then this routine simply allocates a block of n bytes else buf must point to memory that has been dynamically allocated by G_malloc(), G_calloc(), G_realloc(), malloc(3), alloc(3), or realloc(3).. This routine works around broken realloc( ) routines, which do not handle a NULL buf.

Parameters:
buf buffer holding original data
n array size
Returns:
void *

Definition at line 82 of file alloc.c.

References G_fatal_error(), and NULL.

Referenced by G__reallocate_mask_buf(), G__reallocate_null_buf(), G__reallocate_temp_buf(), G__reallocate_work_buf(), G_available_mapsets(), G_extend_histogram(), G_get_raster_row_colors(), G_is_reclassed_to(), G_parser(), G_putenv(), G_rc_path(), G_recreate_command(), G_set_d_raster_cat(), G_set_key_value(), G_tokenize(), and G_update_cell_stats().


Generated on Sun Apr 6 17:32:14 2008 for GRASS by  doxygen 1.5.5