GIS Library - Memory allocation routines. More...
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/glocale.h>
Go to the source code of this file.
Functions | |
void * | G__malloc (const char *file, int line, size_t n) |
Memory allocation. | |
void * | G__calloc (const char *file, int line, size_t m, size_t n) |
Memory allocation. | |
void * | G__realloc (const char *file, int line, void *buf, size_t n) |
Memory reallocation. | |
void | G_free (void *buf) |
Free allocated memory. |
GIS Library - Memory 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.
Definition in file alloc.c.
void* G__calloc | ( | const char * | file, |
int | line, | ||
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 maps is discussed in Allocating_Raster_I_O_Buffers.
[in] | n | number of elements |
[in] | m | element size |
Definition at line 65 of file alloc.c.
References G_fatal_error().
void* G__malloc | ( | const char * | file, |
int | line, | ||
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.
[in] | n |
Definition at line 34 of file alloc.c.
References G_fatal_error().
void* G__realloc | ( | const char * | file, |
int | line, | ||
void * | buf, | ||
size_t | n | ||
) |
Memory reallocation.
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.
[in,out] | buf | buffer holding original data |
[in] | n | array size |
Definition at line 103 of file alloc.c.
References G_fatal_error().
void G_free | ( | void * | buf ) |
Free allocated memory.
[in,out] | buf | buffer holding original data |
Definition at line 127 of file alloc.c.
Referenced by G__color_free_fp_lookup(), G__color_free_lookup(), G__color_free_rules(), G__create_window_mapping(), G__file_name(), G__file_name_misc(), G__get_window(), G__read_Cell_head(), G__read_row_ptrs(), G__write_row_ptrs(), G_ask_datum_name(), G_available_mapsets(), G_close_gdal_link(), G_fpreclass_reset(), G_free_cell_stats(), G_free_histogram(), G_free_key_value(), G_free_list(), G_free_raster_cats(), G_free_reclass(), G_free_tokens(), G_get_cellhd(), G_get_default_window(), G_get_raster_sample_bilinear(), G_get_raster_sample_cubic(), G_get_raster_sample_nearest(), G_get_window(), G_list(), G_ls(), G_plot_area(), G_putenv(), G_quant_add_rule(), G_quant_free(), G_rc_path(), G_set_ask_return_msg(), G_set_d_raster_cat(), G_set_key_value(), G_set_program_name(), and G_vasprintf().