We will not list the memory functions of all GRAPE datatypes here, but give only some examples. These functions exist for all GRAPE datatypes.
INT2 *int2_alloc(size_t nr_of_int2) INT2 *int2_free(INT2 *ptr, size_t nr_of_int2) INT2 **int2_p_alloc(size_t nr_of_int2_p) INT2 **int2_p_free(INT2 **ptr, size_t nr_of_int2_p) VEC3 *vec3_alloc(size_t nr_of_vec3) VEC3 *vec3_free(VEC3 *ptr, size_t nr_of_vec3) VEC3 **vec3_p_alloc(size_t nr_of_vec3_p) VEC3 **vec3_p_free(VEC3 **ptr, size_t nr_of_vec3_p)All these functions work exactly like ones described in the last two section. The names of the identic functions for the other GRAPE datatypes are:
datatype_alloc(size_t nr_of_datatype) datatype_free(datatype *ptr, size_t nr_of_datatype) datatype_realloc(datatype *ptr, size_t old_nr_of_datatype, \ size_t new_nr_of_datatype) g_smart_datatype_realloc(datatype *ptr, size_t nr_of_datatype, \ size_t old_max_nr_of_datatype, size_t new_max_nr_of_datatype) datatype_p_alloc(size_t nr_of_datatype_p) datatype_p_free(datatype **ptr, size_t nr_of_datatype_p)
The _realloc-functions change a block's size and return the maybe changed address, data contained in both blocks is preserved. To save copy time there is a special version of some of the _realloc-functions, called g_smart_datatype_realloc, based on the generic function g_smart_mem_realloc, where you pass the amount of used memory that has to be copied if necessary. In addition these functions check their arguments, complaining about more used then previously allocated memory or more used then new allocated memory. Sometimes only the amount of used memory has been wrongly set, as in this example:
Since "list-alloc" internally uses g_smart_double_realloc you will get this message for the x, y and z arrays of t:{ TRIANG2D *t; int i; t = (TRIANG2D *)GRAPE (Triang2d, "new-instance")("my object"); t->number_of_points = 10; GRAPE (t, "list-alloc")(10, 10); ... /* fill arrays*/ }
Set number_of_points after allocating the lists, which is the correct usage anyway.g_smart_mem_realloc: number > max_number Active Method : 'list-alloc' (Triang2d) [0] Object : "my object" (Triang2d)
A complete list of all existing functions:
void *g_smart_mem_realloc double *double_alloc, double_free, double_realloc, g_smart_double_realloc double **double_p_alloc, double_p_free, double_p_realloc char *char_alloc, char_free, char_realloc, g_smart_char_realloc char **char_p_alloc, char_p_free, char_p_realloc int *int_alloc, int_free, int_realloc, g_smart_int_realloc int **int_p_alloc, int_p_free, int_p_realloc INT2 *int2_alloc, int2_free, int2_realloc, g_smart_int2_realloc INT2 **int2_p_alloc, int2_p_free, int2_p_realloc INT3 *int3_alloc, int3_free, int3_realloc, g_smart_int3_realloc INT3 **int3_p_alloc, int3_p_free, int3_p_realloc INT4 *int4_alloc, int4_free, int4_realloc, g_smart_int4_realloc INT4 **int4_p_alloc, int4_p_free, int4_p_realloc VEC2 *vec2_alloc, vec2_free, vec2_realloc, g_smart_vec2_realloc VEC2 **vec2_p_alloc, vec2_p_free, vec2_p_realloc VEC3 *vec3_alloc, vec3_free, vec3_realloc, g_smart_vec3_realloc VEC3 **vec3_p_alloc, vec3_p_free, vec3_p_realloc VEC4 *vec4_alloc, vec4_free, vec4_realloc, g_smart_vec4_realloc VEC4 **vec4_p_alloc, vec4_p_free, vec4_p_realloc INSTANCE **instance_p_alloc, instance_p_free, instance_p_realloc CHAIN **chain_p_alloc, chain_p_free, chain_p_realloc SPLINE1D **spline1d_p_alloc, spline1d_p_free, spline1d_p_realloc TRIANG1D **triang1d_p_alloc, triang1d_p_free, triang1d_p_realloc TRIANG2D **triang2d_p_alloc, triang2d_p_free, triang2d_p_realloc TRIANG1D ***triang1d_pp_alloc, triang1d_pp_free, triang1d_pp_realloc TRIANG2D ***triang2d_pp_alloc, triang2d_pp_free, triang2d_pp_realloc TRIANG1D ****triang1d_ppp_alloc, triang1d_ppp_free, triang1d_ppp_realloc TRIANG2D ****triang2d_ppp_alloc, triang2d_ppp_free, triang2d_ppp_realloc FUNCTION_RULER **function_ruler_p_alloc, function_ruler_p_free, function_ruler_p_realloc BOUNDED_RULER **bounded_ruler_p_alloc, bounded_ruler_p_free, bounded_ruler_p_realloc RULER **ruler_p_alloc, ruler_p_free, ruler_p_realloc
Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.