Blender V4.3
BLI_memarena.h File Reference

Go to the source code of this file.

Macros

#define BLI_MEMARENA_STD_BUFSIZE   MEM_SIZE_OPTIMAL(1 << 14)
 

Typedefs

typedef struct MemArena MemArena
 

Functions

struct MemArenaBLI_memarena_new (size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
 
void BLI_memarena_free (struct MemArena *ma) ATTR_NONNULL(1)
 
void BLI_memarena_use_malloc (struct MemArena *ma) ATTR_NONNULL(1)
 
void BLI_memarena_use_calloc (struct MemArena *ma) ATTR_NONNULL(1)
 
void BLI_memarena_use_align (struct MemArena *ma, size_t align) ATTR_NONNULL(1)
 
void * BLI_memarena_alloc (struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
 
void * BLI_memarena_calloc (struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
 
void BLI_memarena_merge (MemArena *ma_dst, MemArena *ma_src) ATTR_NONNULL(1
 
void void BLI_memarena_clear (MemArena *ma) ATTR_NONNULL(1)
 

Macro Definition Documentation

◆ BLI_MEMARENA_STD_BUFSIZE

Typedef Documentation

◆ MemArena

typedef struct MemArena MemArena

Definition at line 24 of file BLI_memarena.h.

Function Documentation

◆ BLI_memarena_alloc()

void * BLI_memarena_alloc ( struct MemArena * ma,
size_t size )

Definition at line 118 of file BLI_memarena.c.

References MemArena::align, BLI_asan_poison, BLI_asan_unpoison, MemArena::bufs, MemArena::bufsize, MemArena::curbuf, MemArena::cursize, MemBuf::data, MEM_callocN, MEM_mallocN, memarena_curbuf_align(), MemArena::name, MemBuf::next, PADUP, ptr, size(), UNLIKELY, MemArena::use_calloc, and VALGRIND_MEMPOOL_ALLOC.

Referenced by _bmo_slot_buffer_append(), _bmo_slot_copy(), add_cube(), add_member(), add_new_bound_vert(), blender::geometry::PackIsland::add_polygon(), add_type(), addfillface(), arena_alloc(), arena_realloc(), bevel_build_cutoff(), bevel_vert_construct(), BKE_lnor_spacearr_init(), BKE_mesh_loop_islands_add(), BKE_mesh_loop_islands_init(), BKE_mesh_remap_init(), BLI_astar_node_link_add(), BLI_astar_solution_init(), BLI_linklist_append_arena(), BLI_linklist_prepend_arena(), BLI_memarena_calloc(), BLI_polyfill_beautify(), BLI_polyfill_calc_arena(), BLI_scanfill_edge_add(), BLI_scanfill_vert_add(), blo_cache_storage_entry_register(), bm_face_split_by_edges_island_connect(), BM_face_split_edgenet_connect_islands(), bm_interp_face_store(), bm_isect_edge_tri(), BM_vert_loop_groups_data_layer_create(), bmesh_calc_tessellation_for_face_beauty(), bmesh_calc_tessellation_for_face_impl(), bmo_face_inset_individual(), bmo_inset_region_exec(), BMO_slot_buffer_alloc(), BMO_slot_buffer_from_array(), BMO_slot_buffer_from_single(), BMO_slot_mat_set(), build_bvh_spatial(), build_vmesh(), C_BVHTree_FromPolygons(), calculate_profile(), DNA_member_id_rename(), dynstr_alloc(), blender::geometry::PackIsland::finalize_geometry_(), ghash_insert_face_edge_link(), ghash_insert_link(), init_meta(), insert_seam_vert_array(), knife_empty_list(), math_layer_info_init(), blender::bke::mesh::mesh_calc_tessellation_for_face_impl(), mesh_customdatacorrect_init_container_merge_group(), mesh_customdatacorrect_init_vert(), mesh_remap_item_define(), mesh_tessface_calc(), meshdeform_matrix_solve(), meshdeform_ray_tree_intersect(), new_adj_vmesh(), blender::geometry::new_geo_uv_pinindex(), blender::geometry::p_add_ngon(), blender::geometry::p_face_add(), blender::geometry::p_vert_add(), blender::geometry::p_vert_copy(), blender::bke::pbvh::pbvh_bmesh_node_limit_ensure_fast(), project_paint_build_proj_ima(), project_paint_op(), project_paint_uvpixel_init(), sdna_expand_names(), set_profile_spacing(), setcenter(), setcorner(), setedge(), strdup_memarena(), strdup_memarena_from_dynstr(), UI_view2d_text_cache_add(), UI_view2d_text_cache_add_rectf(), and blender::bke::greasepencil::update_triangle_cache().

◆ BLI_memarena_calloc()

◆ BLI_memarena_clear()

◆ BLI_memarena_free()

void BLI_memarena_free ( struct MemArena * ma)

Definition at line 96 of file BLI_memarena.c.

References MemArena::bufs, MEM_freeN(), memarena_buf_free_all(), and VALGRIND_DESTROY_MEMPOOL.

Referenced by arena_release(), BKE_displist_fill(), BKE_library_make_local(), BKE_lnor_spacearr_free(), BKE_lnor_spacearr_tls_join(), BKE_maskrasterize_handle_init(), BKE_mesh_loop_islands_free(), BKE_mesh_remap_free(), BLI_astar_graph_free(), BLI_astar_solution_free(), BLI_dynstr_free(), BLI_polyfill_calc(), BLI_scanfill_end(), blo_cache_storage_end(), bm_decim_triangulate_begin(), BM_mesh_bevel(), bm_mesh_calc_tessellation__single_threaded(), BM_mesh_calc_tessellation_beauty(), bm_mesh_calc_tessellation_with_partial__single_threaded(), BM_mesh_intersect(), BM_mesh_triangulate(), bmesh_calc_tessellation_for_face_free_fn(), bmesh_calc_tessellation_for_face_partial_free_fn(), bmo_connect_verts_concave_exec(), bmo_inset_individual_exec(), bmo_inset_region_exec(), BMO_op_finish(), C_BVHTree_FromPolygons(), LibOverrideGroupTagData::clear(), DNA_sdna_free(), do_projectpaint_thread(), edbm_face_split_by_edges_exec(), blender::geometry::finalize_geometry(), freepolygonize(), harmonic_coordinates_bind(), knifetool_exit_ex(), layer_bucket_init(), make_structDNA(), menu_search_arg_free_fn(), mesh_customdatacorrect_free(), mesh_tessface_calc(), project_paint_end(), smart_project_exec(), test_polyfill_template(), UI_view2d_text_cache_draw(), blender::bke::greasepencil::update_triangle_cache(), uv_select_overlap(), uvedit_pack_islands_multi(), blender::bke::mesh::LocalData::~LocalData(), and blender::geometry::ParamHandle::~ParamHandle().

◆ BLI_memarena_merge()

void BLI_memarena_merge ( MemArena * ma_dst,
MemArena * ma_src )

Transfer ownership of allocated blocks from ma_src into ma_dst, cleaning the contents of ma_src.

Note
Useful for multi-threaded tasks that need a thread-local MemArena that is kept after the multi-threaded operation is completed.
Avoid accumulating memory pools where possible as any unused memory in ma_src is wasted every merge.

Referenced by BKE_lnor_spacearr_tls_join().

◆ BLI_memarena_new()

struct MemArena * BLI_memarena_new ( size_t bufsize,
const char * name )

Definition at line 66 of file BLI_memarena.c.

References MemArena::align, MemArena::bufsize, MEM_callocN, MemArena::name, and VALGRIND_CREATE_MEMPOOL.

Referenced by _getSubSurf(), BKE_displist_fill(), BKE_library_make_local(), BKE_lnor_spacearr_init(), BKE_lnor_spacearr_tls_init(), BKE_maskrasterize_handle_init(), BKE_mball_polygonize(), BKE_mesh_loop_islands_init(), BKE_mesh_remap_init(), BLI_astar_graph_init(), BLI_astar_solution_init(), BLI_dynstr_new_memarena(), BLI_polyfill_calc(), BLI_scanfill_begin(), blo_cache_storage_init(), bm_decim_triangulate_begin(), BM_mesh_bevel(), BM_mesh_intersect(), BM_mesh_triangulate(), bmesh_calc_tessellation_for_face_beauty(), bmesh_calc_tessellation_for_face_impl(), bmo_connect_verts_concave_exec(), bmo_inset_individual_exec(), bmo_inset_region_exec(), BMO_op_init(), C_BVHTree_FromPolygons(), DNA_sdna_alias_data_ensure(), DNA_sdna_patch_struct_member(), do_projectpaint_thread(), edbm_face_split_by_edges_exec(), blender::geometry::finalize_geometry(), blender::bke::pbvh::Tree::from_bmesh(), harmonic_coordinates_bind(), knifetool_init(), layer_bucket_init(), lib_override_group_tag_data_object_to_collection_init(), make_structDNA(), menu_items_from_ui_create(), blender::bke::mesh::mesh_calc_tessellation_for_face_impl(), mesh_customdatacorrect_create_impl(), mesh_tessface_calc(), blender::geometry::ParamHandle::ParamHandle(), proj_paint_state_thread_init(), smart_project_exec(), test_polyfill_template(), UI_view2d_text_cache_add(), UI_view2d_text_cache_add_rectf(), blender::bke::greasepencil::update_triangle_cache(), uv_select_overlap(), and uvedit_pack_islands_multi().

◆ BLI_memarena_use_align()

void BLI_memarena_use_align ( struct MemArena * ma,
size_t align )

Definition at line 88 of file BLI_memarena.c.

References MemArena::align, and BLI_assert.

◆ BLI_memarena_use_calloc()

void BLI_memarena_use_calloc ( struct MemArena * ma)

Definition at line 78 of file BLI_memarena.c.

References MemArena::use_calloc.

Referenced by BM_mesh_bevel(), BMO_op_init(), and harmonic_coordinates_bind().

◆ BLI_memarena_use_malloc()

void BLI_memarena_use_malloc ( struct MemArena * ma)

Definition at line 83 of file BLI_memarena.c.

References MemArena::use_calloc.