Memory
[libbu (utility functions)]

Collaboration diagram for Memory:


Files

file  malloc.c
 Parallel-protected debugging-enhanced wrapper around system malloc().

Data Structures

struct  memdebug
struct  memqdebug

Defines

#define bu_strdup(s)   bu_strdupm(s, "bu_srtdup " BU_FLSTR)
#define MDB_MAGIC   0x12348969
#define MEMDEBUG_NULL   ((struct memdebug *)0)
#define MEMQDEBUG_NULL   ((struct memqdebug *)0)

Enumerations

enum  alloc_t { MALLOC, CALLOC }

Functions

genptr_t bu_malloc (unsigned int cnt, const char *str)
void bu_free (genptr_t ptr, const char *str)
genptr_t bu_realloc (genptr_t ptr, unsigned int cnt, const char *str)
genptr_t bu_calloc (unsigned int nelem, unsigned int elsize, const char *str)
void bu_prmem (const char *str)
char * bu_strdupm (const char *cp, const char *label)
char * bu_dirname (const char *cp)
int bu_malloc_len_roundup (int nbytes)
void bu_ck_malloc_ptr (genptr_t ptr, const char *str)
int bu_mem_barriercheck ()
HIDDEN void bu_memdebug_add (char *ptr, unsigned int cnt, const char *str)
HIDDEN struct memdebugbu_memdebug_check (register char *ptr, const char *str)
genptr_t bu_realloc (register genptr_t ptr, unsigned int cnt, const char *str)
char * bu_strdupm (register const char *cp, const char *label)
int bu_malloc_len_roundup (register int nbytes)
void bu_free_array (int argc, char *argv[], const char *str)

Variables

long bu_n_malloc
long bu_n_free
long bu_n_realloc
int bu_debug = 0
long bu_n_malloc = 0
long bu_n_free = 0
long bu_n_realloc = 0
const char bu_strdup_message [] = "bu_strdup string"
const char bu_vls_message []

Define Documentation

#define bu_strdup  )     bu_strdupm(s, "bu_srtdup " BU_FLSTR)
 

Definition at line 1992 of file bu.h.

Referenced by bu_avs_add(), bu_avs_add_nonunique(), bu_dirname(), bu_open_mapped_file(), db5_update_ident(), db_dirbuild(), db_dup_subtree(), db_open(), db_scan(), db_string_to_path(), db_tcl_tree_parse(), db_update_ident(), dgo_set_outputHandler_cmd(), Do_copy_membs(), rt_comb_import5(), rt_extrude_import5(), rt_extrude_tcladjust(), rt_extrude_xform(), rt_pr_tree_str(), wdb_combadd(), wdb_move_all_cmd(), and wdb_track_cmd().

#define MDB_MAGIC   0x12348969
 

Definition at line 92 of file malloc.c.

Referenced by bu_ck_malloc_ptr(), bu_free(), bu_mem_barriercheck(), bu_memdebug_add(), bu_memdebug_check(), bu_prmem(), and bu_realloc().

#define MEMDEBUG_NULL   ((struct memdebug *)0)
 

Definition at line 102 of file malloc.c.

Referenced by bu_free(), bu_memdebug_check(), and bu_realloc().

#define MEMQDEBUG_NULL   ((struct memqdebug *)0)
 

Definition at line 111 of file malloc.c.


Enumeration Type Documentation

enum alloc_t
 

used by the memory allocation routines passed to bu_alloc by default to indicate whether allocated memory should be zero'd first.

Enumerator:
MALLOC 
CALLOC 

Definition at line 81 of file malloc.c.


Function Documentation

genptr_t bu_malloc unsigned int  size,
const char *  str
 

B U _ M A L L O C

This routine only returns on successful allocation. We promise never to return a NULL pointer; caller doesn't have to check. Failure results in bu_bomb() being called. w

Definition at line 335 of file malloc.c.

References MALLOC.

Referenced by Add_vert(), bn_gauss_init(), bn_mat_dup(), bn_noise_init(), bn_tabdata_binary_read(), bn_unif_init(), bu_association(), bu_avs_add_nonunique(), bu_bitv_new(), bu_copy_external(), bu_cv_w_cookie(), bu_list_elem(), bu_open_mapped_file(), bu_rb_create(), bu_rb_create1(), bu_rb_delete(), bu_realloc(), bu_strdupm(), bu_struct_export(), bu_struct_get(), bu_vls_extend(), bu_vls_strdup(), bu_vls_vlsinit(), bu_which(), ControlPolygonFlatEnough(), create_vert_tree(), create_vert_tree_w_norms(), db5_export_object3(), db5_get_raw_internal_fp(), db5_realloc(), db_add_node_to_full_path(), db_alloc(), db_argv_to_path(), db_dup_db_tree_state(), db_dup_full_path(), db_dup_path_tail(), db_extend_full_path(), db_get_directory(), db_get_external(), db_getmrec(), db_lookup_by_attr(), db_open(), db_path_to_string(), db_string_to_path(), db_zapper(), dgo_E_cmd(), dgo_init_qray(), dgo_vnirt_cmd(), Do_copy_membs(), do_quad(), do_tri(), eval_etree(), find_closest_face(), FindRoots(), get_seg_midpoint(), heap_increase(), init_heap(), insert_in_bsp(), nmg_booltree_evaluate(), nmg_cnurb_to_vlist(), nmg_eval_linear_trim_to_tol(), nmg_eval_trim_to_tol(), nmg_face_coincident_vu_sort(), nmg_find_outer_and_void_shells(), nmg_isect2d_prep(), nmg_open_shells_connect(), nmg_split_linear_trim(), nmg_split_trim(), nmg_translate_face(), rt_arb_export5(), rt_arb_import(), rt_arb_import5(), rt_arb_setup(), rt_arbn_export(), rt_arbn_export5(), rt_arbn_import(), rt_arbn_import5(), rt_arbn_prep(), rt_ars_import(), rt_ars_import5(), rt_ars_rd_curve(), rt_ars_tcladjust(), rt_bend_pipe_prep(), rt_binunif_export5(), rt_binunif_import5(), rt_bot_decimate(), rt_bot_export5(), rt_bot_import(), rt_bot_sort_faces(), rt_bot_xform(), rt_cline_export5(), rt_cline_import(), rt_cline_import5(), rt_comb_export5(), rt_comb_import5(), rt_conv_uv(), rt_copy_curve(), rt_copy_sketch(), rt_ct_get(), rt_ct_populate_box(), rt_cut_extend(), rt_cut_it(), rt_cut_one_axis(), rt_do_cmd(), rt_dsp_export5(), rt_dsp_import(), rt_dsp_import5(), rt_ehy_export5(), rt_ehy_import(), rt_ehy_import5(), rt_ehy_plot(), rt_ehy_tess(), rt_ell_export5(), rt_ell_import(), rt_ell_import5(), rt_epa_export5(), rt_epa_import(), rt_epa_import5(), rt_epa_plot(), rt_epa_tess(), rt_eto_export5(), rt_eto_import(), rt_eto_import5(), rt_eto_plot(), rt_eto_tess(), rt_extrude_import(), rt_extrude_import5(), rt_extrude_xform(), rt_find_identical_solid(), rt_find_paths(), rt_get_bitv(), rt_get_seg(), rt_gettree_region_end(), rt_gettrees_muves(), rt_grow_boolstack(), rt_grp_export5(), rt_grp_import(), rt_grp_import5(), rt_hf_import(), rt_hlf_export5(), rt_hlf_import(), rt_hlf_import5(), rt_linear_pipe_prep(), rt_load_attrs(), rt_memfree(), rt_metaball_export5(), rt_metaball_import5(), rt_metaball_prep(), rt_mk_binunif(), rt_mk_ell(), rt_nmg_export_fastf(), rt_nmg_import_fastf(), rt_nurb_c_eval(), rt_nurb_c_xsplit(), rt_nurb_cinterp(), rt_nurb_doolittle(), rt_nurb_gen_knot_vector(), rt_nurb_import(), rt_nurb_import5(), rt_nurb_intersect(), rt_nurb_kvcopy(), rt_nurb_kvextract(), rt_nurb_kvgen(), rt_nurb_kvknot(), rt_nurb_kvmerge(), rt_nurb_kvmult(), rt_nurb_mk_poly(), rt_nurb_new_cnurb(), rt_nurb_new_snurb(), rt_nurb_reverse_srf(), rt_nurb_s_eval(), rt_nurb_s_flat(), rt_nurb_s_refine(), rt_nurb_s_xsplit(), rt_nurb_sinterp(), rt_nurb_solve(), rt_part_export5(), rt_part_import(), rt_part_import5(), rt_pg_import(), rt_pg_tess(), rt_pg_to_bot(), rt_pipe_export5(), rt_pipe_import(), rt_pipe_import5(), rt_pipe_prep(), rt_pr_tree_str(), rt_ptalloc(), rt_read_cmd(), rt_rhc_export5(), rt_rhc_import(), rt_rhc_import5(), rt_rhc_plot(), rt_rhc_tess(), rt_rpc_export5(), rt_rpc_import(), rt_rpc_import5(), rt_rpc_plot(), rt_rpc_tess(), rt_sketch_export5(), rt_sketch_import(), rt_sketch_import5(), rt_submodel_import(), rt_submodel_import5(), rt_superell_export5(), rt_superell_import(), rt_superell_import5(), rt_tgc_export5(), rt_tgc_import(), rt_tgc_import5(), rt_tgc_tess(), rt_tgc_vshot(), rt_tor_export5(), rt_tor_import(), rt_tor_import5(), rt_tor_plot(), rt_tor_tess(), rt_tor_vshot(), rt_xxx_import(), rt_xxx_import5(), spm_init(), spm_px_load(), subdivide_bezier(), vfont_get(), wdb_add_operand(), wdb_append_inter(), wdb_append_lparen(), wdb_append_rparen(), wdb_append_subtr(), wdb_append_union(), wdb_do_inter(), wdb_do_union_subtr(), wdb_getspace(), wdb_importFg4Section_cmd(), wdb_make_bb_cmd(), wdb_nmg_simplify_cmd(), wdb_rt_gettrees_cmd(), and wdb_track_cmd().

void bu_free genptr_t  ptr,
const char *  str
 

Definition at line 359 of file malloc.c.

References bu_debug, BU_LIST_DEQUEUE, BU_LIST_MAGIC_WRONG, bu_memdebug_check(), BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), memdebug::mdb_len, MDB_MAGIC, MEMDEBUG_NULL, and memqdebug::q.

Referenced by add_solid(), bn_gauss_free(), bn_tabdata_binary_read(), bn_tabdata_free(), bn_table_free(), bn_unif_free(), bn_vlist_cleanup(), bu_avs_add(), bu_avs_free(), bu_avs_remove(), bu_bitv_free(), bu_delete_hook(), bu_dirname(), bu_free_array(), bu_free_external(), bu_free_mapped_files(), bu_hist_free(), bu_key_val_to_vls(), bu_lex(), bu_list_free(), bu_log_delete_hook(), bu_observer_free(), bu_open_mapped_file(), bu_ptbl_free(), bu_rb_delete(), bu_rb_free(), bu_rb_free_node(), bu_rb_free_package(), bu_shader_to_key_eq(), bu_struct_export(), bu_vls_free(), bu_vls_vlsfree(), classify_sketch_loops(), db5_scan(), db5_update_ident(), db_apply_anims(), db_apply_state_from_comb(), db_apply_state_from_memb(), db_close(), db_delete(), db_dirdelete(), db_do_anim(), db_follow_path(), db_free_1anim(), db_free_combined_tree_state(), db_free_db_tree_state(), db_free_full_path(), db_free_tree(), db_functree(), db_get_external(), db_getmrec(), db_inmem(), db_open(), db_pr_combined_tree_state(), db_pr_full_path(), db_preorder_traverse(), db_recurse(), db_recurse_subtree(), db_string_to_path(), db_tcl_tree_parse(), db_update_ident(), db_walk_subtree(), db_write_anim(), db_zapper(), dgo_build_dpp(), dgo_deleteProc(), dgo_E_cmd(), dgo_eraseobjpath(), dgo_free_qray(), dgo_set_outputHandler_cmd(), dgo_vnirt_cmd(), Do_copy_membs(), eval_op(), FindRoots(), free_etree(), free_vert_tree(), heap_increase(), make_near_list(), nmg_2face_plot(), nmg_bot(), nmg_ck_e(), nmg_ck_eu(), nmg_ck_f(), nmg_ck_fg(), nmg_ck_fu(), nmg_ck_l(), nmg_ck_lg(), nmg_ck_lu(), nmg_ck_vs_in_region(), nmg_ck_vu(), nmg_class_pt_s(), nmg_class_ray_vs_shell(), nmg_count_shell_kids(), nmg_crackshells(), nmg_cut_loop(), nmg_decompose_shell(), nmg_dup_face(), nmg_e_and_v_tabulate(), nmg_edge_g_tabulate(), nmg_edge_tabulate(), nmg_edgeuse_on_line_tabulate(), nmg_edgeuse_tabulate(), nmg_eu_radial_check(), nmg_extrude_face(), nmg_extrude_shell(), nmg_face_lu_plot(), nmg_face_plot(), nmg_face_tabulate(), nmg_find_e_nearest_pt2(), nmg_fix_decomposed_shell_normals(), nmg_fix_normals(), nmg_fix_overlapping_loops(), nmg_has_dangling_faces(), nmg_hollow_shell(), nmg_invert_shell(), nmg_isect2d_cleanup(), nmg_keg(), nmg_move_edge_thru_pt(), nmg_pl_2fu(), nmg_pl_comb_fu(), nmg_pl_isect(), nmg_pl_lu_around_eu(), nmg_plot_lu_around_eu(), nmg_plot_lu_ray(), nmg_plot_ray_face(), nmg_radial_join_eu_NEW(), nmg_rebound(), nmg_s_radial_harmonize(), nmg_shell_coplanar_face_merge(), nmg_shell_is_void(), nmg_shell_manifolds(), nmg_split_loops_into_faces(), nmg_struct_counts(), nmg_triangulate_fu(), nmg_unbreak_region_edges(), nmg_vertex_tabulate(), nmg_vertexuse_normal_tabulate(), nmg_vlblock_s(), Print_tree(), rt_arb_free(), rt_arb_ifree(), rt_arbn_free(), rt_arbn_ifree(), rt_arbn_tcladjust(), rt_ars_ifree(), rt_ars_tcladjust(), rt_bend_pipe_prep(), rt_binunif_free(), rt_binunif_ifree(), rt_bot_ifree(), rt_bot_tcladjust(), rt_clean(), rt_clean_resource(), rt_cline_free(), rt_cline_ifree(), rt_color_free(), rt_comb_export4(), rt_comb_ifree(), rt_comb_import4(), rt_comb_import5(), rt_ct_populate_box(), rt_ct_release_storage(), rt_curve_free(), rt_cut_clean(), rt_cut_it(), rt_del_regtree(), rt_do_cmd(), rt_dsp_free(), rt_dsp_ifree(), rt_ebm_free(), rt_ebm_ifree(), rt_ebm_import(), rt_ebm_import5(), rt_ehy_free(), rt_ehy_ifree(), rt_ehy_import(), rt_ehy_import5(), rt_ehy_plot(), rt_ehy_tess(), rt_ell_free(), rt_ell_ifree(), rt_epa_free(), rt_epa_ifree(), rt_epa_import(), rt_epa_import5(), rt_epa_plot(), rt_epa_tess(), rt_eto_free(), rt_eto_ifree(), rt_extrude_free(), rt_extrude_ifree(), rt_extrude_import(), rt_extrude_import5(), rt_extrude_tcladjust(), rt_extrude_tess(), rt_find_paths(), rt_free_rti(), rt_free_soltab(), rt_grp_free(), rt_grp_ifree(), rt_hf_free(), rt_hf_ifree(), rt_hf_import(), rt_hf_prep(), rt_hlf_free(), rt_hlf_ifree(), rt_htbl_free(), rt_insert_color(), rt_load_attrs(), rt_memclose(), rt_metaball_ifree(), rt_mk_ell(), rt_nmg_describe(), rt_nmg_export_fastf(), rt_nmg_free(), rt_nmg_shot(), rt_nurb_add_hit(), rt_nurb_c_eval(), rt_nurb_c_xsplit(), rt_nurb_cinterp(), rt_nurb_clean_cnurb(), rt_nurb_clean_snurb(), rt_nurb_free_cnurb(), rt_nurb_free_snurb(), rt_nurb_kvmult(), rt_nurb_shot(), rt_nurb_tcladjust(), rt_part_free(), rt_part_ifree(), rt_part_import(), rt_part_import5(), rt_pg_free(), rt_pg_ifree(), rt_pgface(), rt_pipe_export5(), rt_pipe_free(), rt_pipe_hitsort(), rt_pipe_ifree(), rt_pipe_shot(), rt_pipe_tess(), rt_pr_tree_str(), rt_pr_tree_vls(), rt_read_cmd(), rt_rebuild_overlaps(), rt_rec_free(), rt_regionfix(), rt_res_pieces_clean(), rt_rhc_free(), rt_rhc_ifree(), rt_rhc_import(), rt_rhc_import5(), rt_rhc_plot(), rt_rhc_tess(), rt_rpc_free(), rt_rpc_ifree(), rt_rpc_import(), rt_rpc_import5(), rt_rpc_plot(), rt_rpc_tess(), rt_sketch_ifree(), rt_sketch_tcladjust(), rt_smooth_bot(), rt_sph_free(), rt_submodel_free(), rt_submodel_ifree(), rt_submodel_import(), rt_submodel_import5(), rt_submodel_wireframe_leaf(), rt_superell_free(), rt_superell_ifree(), rt_tcl_pr_hit(), rt_tgc_free(), rt_tgc_ifree(), rt_tor_free(), rt_tor_ifree(), rt_vol_free(), rt_vol_ifree(), rt_xxx_free(), rt_xxx_ifree(), spm_free(), subdivide_bezier(), tesselate_pipe_end(), tesselate_pipe_linear(), vfont_free(), vfont_get(), wdb_close(), wdb_combadd(), wdb_concat_cmd(), wdb_do_inter(), wdb_do_paren(), wdb_do_union_subtr(), wdb_dup_cmd(), wdb_eval_bool(), wdb_get_obj_bounds2(), wdb_importFg4Section_cmd(), wdb_move_all_cmd(), wdb_push_cmd(), wdb_shells_cmd(), and XGLUE().

Here is the call graph for this function:

genptr_t bu_realloc genptr_t  ptr,
unsigned int  cnt,
const char *  str
 

Referenced by Add_bot_face(), Add_vert(), bu_avs_add(), bu_avs_add_nonunique(), bu_ptbl_cat(), bu_ptbl_cat_uniq(), bu_ptbl_ins(), bu_struct_get(), bu_vls_extend(), db5_realloc(), db_alloc(), do_grid(), insert_in_bsp(), rt_arbn_tcladjust(), rt_ars_tcladjust(), rt_binunif_tcladjust(), rt_bot_tcladjust(), rt_ct_populate_box(), rt_cut_extend(), rt_htbl_get(), and rt_read_cmd().

genptr_t bu_calloc unsigned int  nelem,
unsigned int  elsize,
const char *  str
 

B U _ C A L L O C

This routine only returns on successful allocation. We promise never to return a NULL pointer; caller doesn't have to check. Failure results in bu_bomb() being called.

Definition at line 349 of file malloc.c.

References CALLOC.

Referenced by Bezier(), bn_tabdata_malloc_array(), bn_vlblock_init(), bu_avs_add(), bu_avs_init(), bu_hist_init(), bu_ptbl_init(), bu_whereis(), bu_which(), create_vert_tree(), create_vert_tree_w_norms(), db5_make_free_object(), db5_make_free_object_hdr(), db_tree_flatten_describe(), dgo_build_dpp(), dgo_eraseobjpath(), facetize_region_end(), FindRoots(), get_tcl_curve(), isect_2D_loop_ray(), nmg_2face_plot(), nmg_bot(), nmg_ck_e(), nmg_ck_eu(), nmg_ck_f(), nmg_ck_fg(), nmg_ck_fu(), nmg_ck_l(), nmg_ck_lg(), nmg_ck_lu(), nmg_ck_vs_in_region(), nmg_ck_vu(), nmg_class_pt_s(), nmg_class_ray_vs_shell(), nmg_complex_vertex_solve(), nmg_count_shell_kids(), nmg_crackshells(), nmg_cut_loop(), nmg_decompose_shell(), nmg_dup_face(), nmg_dup_shell(), nmg_e_and_v_tabulate(), nmg_edge_g_cnurb(), nmg_edge_g_tabulate(), nmg_edge_tabulate(), nmg_edgeuse_on_line_tabulate(), nmg_edgeuse_tabulate(), nmg_enlist_one_vu(), nmg_enlist_vu(), nmg_extrude_face(), nmg_extrude_shell(), nmg_face_g_snurb(), nmg_face_lu_plot(), nmg_face_plot(), nmg_face_tabulate(), nmg_find_e_nearest_pt2(), nmg_fix_decomposed_shell_normals(), nmg_flatten_face(), nmg_has_dangling_faces(), nmg_hollow_shell(), nmg_invert_shell(), nmg_isect_eu_fu(), nmg_m_struct_count(), nmg_manifolds(), nmg_move_edge_thru_pt(), nmg_pl_2fu(), nmg_pl_comb_fu(), nmg_pl_isect(), nmg_pl_lu_around_eu(), nmg_plot_lu_around_eu(), nmg_plot_lu_ray(), nmg_plot_ray_face(), nmg_polytonmg(), nmg_rebound(), nmg_shell_coplanar_face_merge(), nmg_shell_is_void(), nmg_shell_manifolds(), nmg_show_broken_classifier_stuff(), nmg_snurb_calc_lu_uv_orient(), nmg_split_loops_into_faces(), nmg_to_poly(), nmg_unbreak_region_edges(), nmg_vertex_tabulate(), nmg_vertexuse_normal_tabulate(), nmg_vlblock_s(), remove_from_bsp(), rt_arb_export(), rt_arbn_export(), rt_arbn_tess(), rt_ars_export(), rt_ars_export5(), rt_ars_import5(), rt_binunif_make(), rt_bot_condense(), rt_bot_export(), rt_bot_find_e_nearest_pt2(), rt_bot_import(), rt_bot_import5(), rt_bot_sort_faces(), rt_bot_tcladjust(), rt_bot_tess(), rt_bot_xform(), rt_cline_export(), rt_cline_tess(), rt_comb_export4(), rt_comb_export5(), rt_comb_import4(), rt_comb_make(), rt_copy_curve(), rt_copy_sketch(), rt_cut_one_axis(), rt_dsp_export(), rt_dsp_make(), rt_ebm_export(), rt_ebm_export5(), rt_ebm_import(), rt_ebm_import5(), rt_ebm_make(), rt_ebm_tess(), rt_ehy_export(), rt_ell_export(), rt_ell_tess(), rt_epa_export(), rt_epa_tess(), rt_eto_export(), rt_eto_tess(), rt_extrude_export(), rt_extrude_export5(), rt_extrude_import(), rt_extrude_tess(), rt_generic_make(), rt_gettree_region_end(), rt_grp_export(), rt_hf_export(), rt_hf_import(), rt_hlf_export(), rt_htbl_init(), rt_load_attrs(), rt_nmg_export5(), rt_nmg_export_internal(), rt_nmg_shot(), rt_nurb_import5(), rt_nurb_sinterp(), rt_nurb_tcladjust(), rt_part_export(), rt_part_tess(), rt_pg_export(), rt_pg_to_bot(), rt_pipe_export(), rt_pipe_tcladjust(), rt_pipe_tess(), rt_prep_parallel(), rt_reprep(), rt_res_pieces_init(), rt_rhc_export(), rt_rhc_tess(), rt_rpc_export(), rt_rpc_tess(), rt_shootray(), rt_sketch_import(), rt_sketch_import5(), rt_smooth_bot(), rt_submodel_export(), rt_submodel_export5(), rt_superell_export(), rt_tgc_export(), rt_tor_export(), rt_vol_export(), rt_vol_export5(), rt_vol_import(), rt_vol_import5(), rt_xxx_export(), rt_xxx_export5(), subdivide_bezier(), tcl_obj_to_fastf_array(), tcl_obj_to_int_array(), tesselate_pipe_bend(), tesselate_pipe_end(), tesselate_pipe_linear(), wdb_combadd(), and XGLUE().

void bu_prmem const char *  str  ) 
 

B U _ P R M E M

Print map of memory currently in use.

Definition at line 515 of file malloc.c.

References bu_bomb(), bu_debug, bu_strdup_message, bu_vls_message, memdebug::magic, memdebug::mdb_addr, memdebug::mdb_len, MDB_MAGIC, and memdebug::mdb_str.

Referenced by bu_tcl_prmem().

Here is the call graph for this function:

char* bu_strdupm const char *  cp,
const char *  label
 

char * bu_dirname const char *  cp  ) 
 

B U _ D I R N A M E

Given a filesystem pathname, return a pointer to a dynamic string which is the parent directory of that file/directory.

/usr/dir/file /usr/dir
/usr/dir/ /usr
/usr/file /usr
/usr/ /
/usr /
/ /
. .
.. .
usr .
a/b a
a/ .
../a/b ../a

Definition at line 641 of file malloc.c.

References bu_free(), bu_strdup, and NULL.

Referenced by db_open().

Here is the call graph for this function:

int bu_malloc_len_roundup int  nbytes  ) 
 

Referenced by bu_tcl_malloc_len_roundup(), db_get_directory(), rt_ct_get(), rt_get_bitv(), and rt_get_seg().

void bu_ck_malloc_ptr genptr_t  ptr,
const char *  str
 

B U _ C K _ M A L L O C _ P T R

For a given pointer allocated by bu_malloc(), Check the magic number stored after the allocation area when BU_DEBUG_MEM_CHECK is set.

This is the individual version of bu_mem_barriercheck().

returns if pointer good or BU_DEBUG_MEM_CHECK not set, bombs if memory is corrupted.

Definition at line 736 of file malloc.c.

References bu_bomb(), bu_debug, memdebug::magic, memdebug::mdb_addr, memdebug::mdb_len, MDB_MAGIC, and NULL.

Referenced by bu_tcl_ck_malloc_ptr().

Here is the call graph for this function:

int bu_mem_barriercheck void   ) 
 

B U _ M E M _ B A R R I E R C H E C K

Check *all* entries in the memory debug table for barrier word corruption. Intended to be called periodicly through an application during debugging. Has to run single-threaded, to prevent table mutation.

This is the bulk version of bu_ck_malloc_ptr()

Returns - -1 something is wrong 0 all is OK;

Definition at line 796 of file malloc.c.

References bu_bomb(), BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), memdebug::magic, and MDB_MAGIC.

Referenced by Add_bot_face(), bu_tcl_mem_barriercheck(), curve_to_vlist(), dgo_E_cmd(), do_grid(), do_tri(), main(), rt_copy_sketch(), rt_extrude_xform(), rt_sketch_export(), rt_sketch_export5(), rt_sketch_ifree(), rt_sketch_import(), rt_sketch_import5(), and shoot_and_plot().

Here is the call graph for this function:

HIDDEN void bu_memdebug_add char *  ptr,
unsigned int  cnt,
const char *  str
 

B U _ M E M D E B U G _ A D D

Add another entry to the memory debug table

Definition at line 131 of file malloc.c.

References BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), memdebug::magic, memdebug::mdb_addr, memdebug::mdb_len, MDB_MAGIC, memdebug::mdb_str, and top().

Here is the call graph for this function:

HIDDEN struct memdebug* bu_memdebug_check register char *  ptr,
const char *  str
 

B U _ M E M D E B U G _ C H E C K

Check an entry against the memory debug table, based upon it's address.

Definition at line 193 of file malloc.c.

References bu_bomb(), BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), memdebug::magic, memdebug::mdb_addr, memdebug::mdb_len, MDB_MAGIC, memdebug::mdb_str, and MEMDEBUG_NULL.

Referenced by bu_free(), and bu_realloc().

Here is the call graph for this function:

genptr_t bu_realloc register genptr_t  ptr,
unsigned int  cnt,
const char *  str
 

B U _ R E A L L O C

bu_malloc()/bu_free() compatible wrapper for realloc().

While the string 'str' is provided for the log messages, don't disturb the mdb_str value, so that this storage allocation can be tracked back to it's original creator.

Definition at line 413 of file malloc.c.

References BU_ASSERT, bu_bomb(), bu_debug, BU_LIST_APPEND, BU_LIST_DEQUEUE, BU_LIST_MAGIC_SET, BU_LIST_MAGIC_WRONG, BU_LIST_NULL, bu_malloc(), bu_memdebug_check(), bu_n_realloc, BU_SEM_SYSCALL, bu_semaphore_acquire(), bu_semaphore_release(), memqdebug::m, memdebug::magic, memdebug::mdb_addr, memdebug::mdb_len, MDB_MAGIC, memdebug::mdb_str, MEMDEBUG_NULL, NULL, ptr, memqdebug::q, realloc(), and sbrk().

Here is the call graph for this function:

char* bu_strdupm register const char *  cp,
const char *  label
 

B U _ S T R D U P

Given a string, allocate enough memory to hold it using bu_malloc(), duplicate the strings, returns a pointer to the new string.

Definition at line 603 of file malloc.c.

References bu_debug, bu_malloc(), BU_SEM_SYSCALL, bu_semaphore_acquire(), and bu_semaphore_release().

Here is the call graph for this function:

int bu_malloc_len_roundup register int  nbytes  ) 
 

B U _ M A L L O C _ L E N _ R O U N D U P

On systems with the CalTech malloc(), the amount of storage ACTUALLY ALLOCATED is the amount requested rounded UP to the nearest power of two. For structures which are acquired and released often, this works well, but for structures which will remain unchanged for the duration of the program, this wastes as much as 50% of the address space (and usually memory as well). Here, we round up a byte size to the nearest power of two, leaving off the malloc header, so as to ask for storage without wasting any.

On systems with the traditional malloc(), this strategy will just consume the memory in somewhat larger chunks, but overall little unused memory will be consumed.

Definition at line 696 of file malloc.c.

void bu_free_array int  argc,
char *  argv[],
const char *  str
 

b u _ f r e e _ a r r a y

free up to argc elements of memory allocated to an array without free'ing the array itself.

Definition at line 833 of file malloc.c.

References bu_free(), and NULL.

Here is the call graph for this function:


Variable Documentation

long bu_n_malloc
 

Definition at line 88 of file malloc.c.

long bu_n_free
 

Definition at line 89 of file malloc.c.

long bu_n_realloc
 

Definition at line 90 of file malloc.c.

Referenced by bu_realloc().

int bu_debug = 0
 

this variable controls the libbu debug level

Definition at line 74 of file malloc.c.

Referenced by Add_bot_face(), bn_2line3_colinear(), bn_between(), bn_ck_table(), bn_dist_line3_pt3(), bn_dist_pt2_along_line2(), bn_dist_pt2_lseg2(), bn_dist_pt3_lseg3(), bn_distsq_line3_pt3(), bn_isect_line2_line2(), bn_isect_line2_lseg2(), bn_isect_line_lseg(), bn_isect_lseg2_lseg2(), bn_isect_lseg3_lseg3(), bn_isect_planes(), bn_isect_pt2_lseg2(), bn_mat_ck(), bn_print_table_and_tabdata(), bn_read_table_and_tabdata(), bn_tabdata_add(), bn_tabdata_area1(), bn_tabdata_area2(), bn_tabdata_binary_read(), bn_tabdata_blend2(), bn_tabdata_blend3(), bn_tabdata_constval(), bn_tabdata_copy(), bn_tabdata_dup(), bn_tabdata_free(), bn_tabdata_freq_shift(), bn_tabdata_get_constval(), bn_tabdata_incr_mul2_scale(), bn_tabdata_incr_mul3_scale(), bn_tabdata_join1(), bn_tabdata_join2(), bn_tabdata_malloc_array(), bn_tabdata_mk_linear_filter(), bn_tabdata_mul(), bn_tabdata_mul3(), bn_tabdata_mul_area1(), bn_tabdata_mul_area2(), bn_tabdata_resample_avg(), bn_tabdata_resample_max(), bn_tabdata_scale(), bn_tabdata_to_tcl(), bn_table_delete_sample_pts(), bn_table_find_x(), bn_table_free(), bn_table_lin_interp(), bn_table_make_uniform(), bn_table_merge2(), bn_table_read(), bn_table_scale(), bn_table_write(), bu_avail_cpus(), bu_avs_init(), bu_avs_new(), bu_bomb(), bu_brlcad_data(), bu_brlcad_root(), bu_ck_malloc_ptr(), bu_close_mapped_file(), bu_file_exists(), bu_free(), bu_free_mapped_files(), bu_nice_set(), bu_open_mapped_file(), bu_parallel(), bu_prmem(), bu_ptbl_cat(), bu_ptbl_cat_uniq(), bu_ptbl_free(), bu_ptbl_init(), bu_ptbl_ins(), bu_ptbl_ins_unique(), bu_ptbl_reset(), bu_ptbl_rm(), bu_realloc(), bu_strdupm(), bu_tcl_setup(), curve_to_vlist(), db5_export_attributes(), db5_import_attributes(), dgo_E_cmd(), do_tri(), main(), rt_bomb(), rt_copy_sketch(), rt_extrude_xform(), rt_htbl_free(), rt_htbl_init(), rt_htbl_reset(), rt_sketch_export(), rt_sketch_export5(), rt_sketch_ifree(), rt_sketch_import(), rt_sketch_import5(), rt_spect_black_body(), rt_spect_black_body_fast(), rt_spect_black_body_points(), and shoot_and_plot().

long bu_n_malloc = 0
 

Definition at line 88 of file malloc.c.

long bu_n_free = 0
 

Definition at line 89 of file malloc.c.

long bu_n_realloc = 0
 

Definition at line 90 of file malloc.c.

Referenced by bu_realloc().

const char bu_strdup_message[] = "bu_strdup string"
 

Definition at line 113 of file malloc.c.

Referenced by bu_prmem().

const char bu_vls_message[]
 

Definition at line 74 of file vls.c.

Referenced by bu_prmem().


Generated on Mon Sep 18 01:25:20 2006 for BRL-CAD by  doxygen 1.4.6