GRASS Programmer's Manual
6.5.svn(2014)-r66266
|
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. More... | |
void * | G__calloc (const char *file, int line, size_t m, size_t n) |
Memory allocation. More... | |
void * | G__realloc (const char *file, int line, void *buf, size_t n) |
Memory reallocation. More... | |
void | G_free (void *buf) |
Free allocated memory. More... | |
GIS Library - Memory allocation routines.
(C) 1999-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.
Definition in file gis/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 68 of file gis/alloc.c.
References buf, G_fatal_error(), G_get_window(), and G_important_message().
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 30 of file gis/alloc.c.
References buf, G_fatal_error(), G_get_window(), G_important_message(), and malloc().
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 111 of file gis/alloc.c.
References buf, G_fatal_error(), G_get_window(), G_important_message(), and malloc().
void G_free | ( | void * | buf | ) |
Free allocated memory.
[in,out] | buf | buffer holding original data |
Definition at line 142 of file gis/alloc.c.
References free().
Referenced by append_item(), class_equiprob(), wxdigit.IVDigit::CopyCats(), create_pad(), D_symbol(), D_symbol2(), db__copy_table(), db_CatValArray_free(), db_read_dbmscap(), db_select_CatValArray(), db_select_int(), db_select_value(), delete_pad(), destroy_si_struct(), dig__frealloc(), dig_cidx_free(), dig_file_free(), dig_file_load(), dig_free_plus_areas(), dig_free_plus_isles(), dig_free_plus_lines(), dig_free_plus_nodes(), E_edit_cats(), err(), font_init_charset(), font_init_freetype(), free_datum_list(), free_ellps_list(), free_font_list(), free_freetypecap(), free_slice_buff(), free_vol_buff(), free_volfile_buffs(), 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_fmatrix(), G_free_fvector(), G_free_histogram(), G_free_imatrix(), G_free_ivector(), G_free_key_value(), G_free_list(), G_free_matrix(), G_free_raster_cats(), G_free_reclass(), G_free_tokens(), G_free_vector(), G_get_cellhd(), G_get_default_window(), G_get_null_value_row(), G_get_raster_sample_bilinear(), G_get_raster_sample_cubic(), G_get_raster_sample_nearest(), G_get_window(), G_list(), G_ls(), G_math_egvorder(), G_math_free_spmatrix(), G_math_free_spvector(), G_math_solver_lu(), G_math_solver_sparse_gs(), G_math_solver_sparse_jacobi(), G_plot_area(), G_put_reclass(), G_putenv(), G_quant_add_rule(), G_quant_free(), G_rc_path(), G_read_color_rules(), G_set_ask_return_msg(), G_set_d_raster_cat(), G_set_key_value(), G_set_program_name(), G_site_free_struct(), G_site_new_struct(), G_sites_close(), G_vasprintf(), gk_free_key(), gk_make_framesfromkeys(), gk_make_linear_framesfromkeys(), gp_free_site(), gp_free_sitemem(), Gp_load_sites(), GPJ_ask_datum_params(), GPJ_free_datum(), GPJ_free_datum_transform(), GPJ_free_ellps(), GPJ_grass_to_osr(), GPJ_osr_to_grass(), GPJ_set_csv_loc(), GS_coordpair_repeats(), gs_free_surf(), Gs_get_cat_label(), gs_init_normbuff(), Gs_loadmap_as_bitmap(), Gs_loadmap_as_char(), Gs_loadmap_as_float(), Gs_loadmap_as_int(), Gs_loadmap_as_short(), gs_malloc_lookup(), Gs_pack_colors(), Gs_pack_colors_float(), gs_set_att_src(), GS_write_ppm(), GS_write_tif(), gsd_put_legend(), gsd_wall(), gsd_write_mpegframe(), gsds_free_datah(), gv_free_vect(), gv_free_vectmem(), Gv_load_vect(), gvd_vect(), gvl_file_free_datah(), gvl_file_set_mode(), gvl_free_vol(), gvl_isosurf_calc(), GVL_isosurf_del(), gvl_isosurf_freemem(), Gvl_load_colors_data(), GVL_slice_del(), gvl_slice_freemem(), Gvl_unload_colors_data(), I_alloc_double3(), I_free(), I_free_double2(), I_free_double3(), I_free_int2(), IL_interp_segments_2d(), IL_resample_interp_segments_2d(), make_mapset(), N_assemble_les_2d_param(), N_assemble_les_3d_param(), N_free_array_2d(), N_free_array_3d(), N_free_geom_data(), N_free_gradient_2d(), N_free_gradient_3d(), N_free_gradient_field_2d(), N_free_gradient_field_3d(), N_free_gradient_neighbours_2d(), N_free_gradient_neighbours_3d(), N_free_gradient_neighbours_x(), N_free_gradient_neighbours_y(), N_free_gradient_neighbours_z(), N_free_gwflow_data2d(), N_free_gwflow_data3d(), N_free_les(), N_free_solute_transport_data2d(), N_free_solute_transport_data3d(), N_init_geom_data_2d(), NetA_allpairs(), NetA_articulation_points(), NetA_betweenness_closeness(), NetA_compute_bridges(), NetA_eigenvector_centrality(), NetA_find_path(), NetA_flow(), NetA_min_cut(), NetA_spanning_tree(), NetA_strongly_connected_components(), NetA_timetable_result_release(), NetA_weakly_connected_components(), Nviz_delete_scalebar(), Nviz_destroy_data(), Nviz_destroy_render_window(), Nviz_draw_all_site(), Nviz_draw_all_surf(), Nviz_draw_all_vol(), Nviz_get_exag(), Nviz_new_fringe(), Nviz_new_map_obj(), Nviz_set_arrow(), Nviz_set_focus_map(), Nviz_set_fringe(), Nviz_set_scalebar(), pg_destroy_struct(), pj_do_transform(), pj_get_kv(), PNG_Graph_close(), R_pad_freelist(), R_parse_monitorcap(), read_pgm(), read_png(), read_ppm(), set_proj_lib(), wxnviz.Nviz::SetWireColor(), Vect_break_lines_list(), Vect_break_polygons(), Vect_close(), Vect_destroy_cat_list(), Vect_destroy_cats_struct(), Vect_destroy_line_struct(), Vect_destroy_list(), Vect_new_varray(), Vect_set_comment(), Vect_set_date(), Vect_set_map_date(), Vect_set_map_name(), Vect_set_organization(), Vect_set_person(), Vect_set_varray_from_db(), Vect_snap_line(), Vect_snap_lines_list(), Vect_subst_var(), write_pgm(), write_png(), and write_ppm().