Blender
V3.3
|
Efficient memory allocation for many small chunks. More...
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_asan.h"
#include "BLI_memarena.h"
#include "BLI_strict_flags.h"
#include "BLI_utildefines.h"
Go to the source code of this file.
Classes | |
struct | MemBuf |
struct | MemArena |
Macros | |
#define | VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed) UNUSED_VARS(pool, rzB, is_zeroed) |
#define | VALGRIND_DESTROY_MEMPOOL(pool) UNUSED_VARS(pool) |
#define | VALGRIND_MEMPOOL_ALLOC(pool, addr, size) UNUSED_VARS(pool, addr, size) |
#define | VALGRIND_MOVE_MEMPOOL(pool_a, pool_b) UNUSED_VARS(pool_a, pool_b) |
#define | PADUP(num, amt) (((num) + ((amt)-1)) & ~((amt)-1)) |
Functions | |
static void | memarena_buf_free_all (struct MemBuf *mb) |
MemArena * | BLI_memarena_new (const size_t bufsize, const char *name) |
void | BLI_memarena_use_calloc (MemArena *ma) |
void | BLI_memarena_use_malloc (MemArena *ma) |
void | BLI_memarena_use_align (struct MemArena *ma, const size_t align) |
void | BLI_memarena_free (MemArena *ma) |
static void | memarena_curbuf_align (MemArena *ma) |
void * | BLI_memarena_alloc (MemArena *ma, size_t size) |
void * | BLI_memarena_calloc (MemArena *ma, size_t size) |
void | BLI_memarena_merge (MemArena *ma_dst, MemArena *ma_src) |
void | BLI_memarena_clear (MemArena *ma) |
Efficient memory allocation for many small chunks.
Memory arena's are commonly used when the program needs to quickly allocate lots of little bits of data, which are all freed at the same moment.
Definition in file BLI_memarena.c.
#define PADUP | ( | num, | |
amt | |||
) | (((num) + ((amt)-1)) & ~((amt)-1)) |
Pad num up by amt (must be power of two).
Definition at line 104 of file BLI_memarena.c.
#define VALGRIND_CREATE_MEMPOOL | ( | pool, | |
rzB, | |||
is_zeroed | |||
) | UNUSED_VARS(pool, rzB, is_zeroed) |
Definition at line 29 of file BLI_memarena.c.
#define VALGRIND_DESTROY_MEMPOOL | ( | pool | ) | UNUSED_VARS(pool) |
Definition at line 30 of file BLI_memarena.c.
#define VALGRIND_MEMPOOL_ALLOC | ( | pool, | |
addr, | |||
size | |||
) | UNUSED_VARS(pool, addr, size) |
Definition at line 31 of file BLI_memarena.c.
#define VALGRIND_MOVE_MEMPOOL | ( | pool_a, | |
pool_b | |||
) | UNUSED_VARS(pool_a, pool_b) |
Definition at line 32 of file BLI_memarena.c.
Definition at line 116 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(), add_cube(), add_name(), add_new_bound_vert(), add_type(), addfillface(), arena_alloc(), arena_realloc(), bevel_build_cutoff(), bevel_vert_construct(), BKE_blendfile_link_append_context_item_add(), BKE_blendfile_link_append_context_library_add(), 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_elem_id_rename(), dynstr_alloc(), ghash_insert_face_edge_link(), ghash_insert_link(), imb_global_cache_get_tile(), imb_thread_cache_init(), init_meta(), insert_seam_vert_array(), knife_empty_list(), math_layer_info_init(), mesh_calc_tessellation_for_face_impl(), mesh_remap_item_define(), mesh_tessface_calc(), meshdeform_matrix_solve(), meshdeform_ray_tree_intersect(), new_adj_vmesh(), new_geo_uv_pinindex(), p_add_ngon(), p_face_add(), p_vert_add(), p_vert_copy(), 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(), split_faces_prepare_new_edges(), split_faces_prepare_new_verts(), strdup_memarena(), strdup_memarena_from_dynstr(), tc_mesh_customdatacorrect_init_container_merge_group(), tc_mesh_customdatacorrect_init_vert(), UI_view2d_text_cache_add(), and UI_view2d_text_cache_add_rectf().
Definition at line 153 of file BLI_memarena.c.
References BLI_assert, BLI_memarena_alloc(), ptr, size(), and MemArena::use_calloc.
Referenced by BKE_blendfile_link_append_context_item_add(), BKE_blendfile_link_append_context_library_add(), BKE_blendfile_link_append_context_new(), BKE_lnor_space_create(), BKE_lnor_spacearr_init(), BLI_astar_graph_init(), lib_override_group_tag_data_object_to_collection_init_collection_process(), menu_items_from_all_operators(), menu_items_from_ui_create(), menu_items_from_ui_create_item_from_button(), and mesh_island_to_astar_graph().
Clear for reuse, avoids re-allocation when an arena may otherwise be free'd and recreated.
Definition at line 208 of file BLI_memarena.c.
References BLI_asan_poison, MemArena::bufs, MemArena::curbuf, MemArena::cursize, MemBuf::data, memarena_buf_free_all(), memarena_curbuf_align(), MemBuf::next, NULL, MemArena::use_calloc, VALGRIND_CREATE_MEMPOOL, and VALGRIND_DESTROY_MEMPOOL.
Referenced by BKE_lnor_spacearr_clear(), BKE_mesh_loop_islands_clear(), BLI_astar_solution_clear(), BLI_dynstr_clear(), BLI_scanfill_end_arena(), BM_face_triangulate(), BM_mesh_intersect(), bmesh_calc_tessellation_for_face_beauty(), bmesh_calc_tessellation_for_face_impl(), bmo_inset_individual_exec(), C_BVHTree_FromPolygons(), edbm_face_split_by_edges_exec(), knife_make_face_cuts(), mesh_calc_tessellation_for_face_impl(), mesh_tessface_calc(), p_add_ngon(), and smart_project_exec().
Definition at line 94 of file BLI_memarena.c.
References MemArena::bufs, MEM_freeN, memarena_buf_free_all(), and VALGRIND_DESTROY_MEMPOOL.
Referenced by arena_release(), BKE_blendfile_link_append_context_free(), 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(), BKE_pbvh_build_bmesh(), 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(), DNA_sdna_free(), do_projectpaint_thread(), edbm_face_split_by_edges_exec(), freepolygonize(), GEO_uv_parametrizer_delete(), harmonic_coordinates_bind(), imb_tile_cache_exit(), knifetool_exit_ex(), layer_bucket_init(), lib_override_group_tag_data_clear(), make(), make_structDNA(), menu_search_arg_free_fn(), mesh_calc_tessellation_for_face_free_fn(), mesh_recalc_looptri__single_threaded(), mesh_tessface_calc(), project_paint_end(), smart_project_exec(), tc_mesh_customdatacorrect_free(), test_polyfill_template(), and UI_view2d_text_cache_draw().
Definition at line 166 of file BLI_memarena.c.
References MemArena::align, BLI_assert, MemArena::bufs, MemArena::bufsize, MemArena::curbuf, MemArena::cursize, MemBuf::next, NULL, UNLIKELY, MemArena::use_calloc, VALGRIND_CREATE_MEMPOOL, and VALGRIND_MOVE_MEMPOOL.
MemArena* BLI_memarena_new | ( | const size_t | bufsize, |
const char * | name | ||
) |
Definition at line 64 of file BLI_memarena.c.
References MemArena::align, MemArena::bufsize, MEM_callocN, MemArena::name, and VALGRIND_CREATE_MEMPOOL.
Referenced by _getSubSurf(), BKE_blendfile_link_append_context_new(), 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(), BKE_pbvh_build_bmesh(), 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_nr(), do_projectpaint_thread(), edbm_face_split_by_edges_exec(), GEO_uv_parametrizer_construct_begin(), harmonic_coordinates_bind(), IMB_tile_cache_params(), knifetool_init(), layer_bucket_init(), lib_override_group_tag_data_object_to_collection_init(), make(), make_structDNA(), menu_items_from_ui_create(), mesh_calc_tessellation_for_face_impl(), mesh_tessface_calc(), proj_paint_state_thread_init(), smart_project_exec(), tc_mesh_customdatacorrect_create_impl(), test_polyfill_template(), UI_view2d_text_cache_add(), and UI_view2d_text_cache_add_rectf().
Definition at line 86 of file BLI_memarena.c.
References MemArena::align, and BLI_assert.
Definition at line 76 of file BLI_memarena.c.
References MemArena::use_calloc.
Referenced by BM_mesh_bevel(), BMO_op_init(), harmonic_coordinates_bind(), and IMB_tile_cache_params().
Definition at line 81 of file BLI_memarena.c.
References MemArena::use_calloc.
Definition at line 51 of file BLI_memarena.c.
References BLI_asan_unpoison, MEM_allocN_len, MEM_freeN, MemBuf::next, and NULL.
Referenced by BLI_memarena_clear(), and BLI_memarena_free().
Align alloc'ed memory (needed if align > 8
).
Definition at line 107 of file BLI_memarena.c.
References MemArena::align, MemArena::curbuf, MemArena::cursize, and PADUP.
Referenced by BLI_memarena_alloc(), and BLI_memarena_clear().