Blender
V3.3
|
#include <stdlib.h>
#include <string.h>
#include "atomic_ops.h"
#include "BLI_utildefines.h"
#include "BLI_memblock.h"
#include "MEM_guardedalloc.h"
#include "BLI_strict_flags.h"
Go to the source code of this file.
Classes | |
struct | BLI_memblock |
Macros | |
#define | CHUNK_LIST_SIZE 16 |
Functions | |
BLI_memblock * | BLI_memblock_create_ex (uint elem_size, uint chunk_size) |
void | BLI_memblock_destroy (BLI_memblock *mblk, MemblockValFreeFP free_callback) |
void | BLI_memblock_clear (BLI_memblock *mblk, MemblockValFreeFP free_callback) |
void * | BLI_memblock_alloc (BLI_memblock *mblk) |
void | BLI_memblock_iternew (BLI_memblock *mblk, BLI_memblock_iter *iter) |
void * | BLI_memblock_iterstep (BLI_memblock_iter *iter) |
void * | BLI_memblock_elem_get (BLI_memblock *mblk, int chunk, int elem) |
Dead simple, fast memory allocator for allocating many elements of the same size.
Definition in file BLI_memblock.c.
#define CHUNK_LIST_SIZE 16 |
Definition at line 24 of file BLI_memblock.c.
void* BLI_memblock_alloc | ( | BLI_memblock * | mblk | ) |
Definition at line 115 of file BLI_memblock.c.
References BLI_memblock::chunk_len, BLI_memblock::chunk_list, CHUNK_LIST_SIZE, BLI_memblock::chunk_max_ofs, BLI_memblock::chunk_next, BLI_memblock::chunk_size, BLI_memblock::elem_last, BLI_memblock::elem_next, BLI_memblock::elem_next_ofs, BLI_memblock::elem_size, MEM_mallocN_aligned, MEM_recallocN, NULL, ptr, and UNLIKELY.
Referenced by draw_unit_state_create(), drw_command_create(), DRW_pass_create(), drw_resource_handle_new(), DRW_shgroup_call_buffer(), DRW_shgroup_call_buffer_instance(), drw_shgroup_create_ex(), DRW_shgroup_create_sub(), drw_shgroup_material_texture(), drw_shgroup_uniform_create_ex(), DRW_temp_batch_instance_request(), DRW_temp_batch_request(), DRW_temp_buffer_request(), DRW_view_create(), DRW_view_create_sub(), gpencil_layer_cache_add(), gpencil_light_pool_add(), gpencil_material_pool_add(), gpencil_object_cache_add(), gpencil_vfx_pass_create(), material_opaque(), workbench_material_chunk_select(), workbench_material_ubo_alloc(), and workbench_private_data_init().
void BLI_memblock_clear | ( | BLI_memblock * | mblk, |
MemblockValFreeFP | free_callback | ||
) |
Reset elem count to 0 but keep as much memory allocated needed for at least the previous elem count.
Definition at line 86 of file BLI_memblock.c.
References BLI_memblock::chunk_len, BLI_memblock::chunk_list, CHUNK_LIST_SIZE, BLI_memblock::chunk_next, BLI_memblock::chunk_size, BLI_memblock::elem_last, BLI_memblock::elem_next, BLI_memblock::elem_next_ofs, BLI_memblock::elem_size, MEM_recallocN, MEM_SAFE_FREE, and UNLIKELY.
Referenced by DRW_instance_buffer_finish(), drw_viewport_data_reset(), EEVEE_materials_cache_init(), GPENCIL_engine_init(), and workbench_update_material_ubos().
BLI_memblock* BLI_memblock_create_ex | ( | uint | elem_size, |
uint | chunk_size | ||
) |
Definition at line 47 of file BLI_memblock.c.
References BLI_assert, BLI_memblock::chunk_len, BLI_memblock::chunk_list, CHUNK_LIST_SIZE, BLI_memblock::chunk_max_ofs, BLI_memblock::chunk_next, BLI_memblock::chunk_size, blender::io::obj::chunk_size, BLI_memblock::elem_last, BLI_memblock::elem_next, BLI_memblock::elem_next_ofs, BLI_memblock::elem_size, MEM_callocN, MEM_mallocN, and MEM_mallocN_aligned.
Referenced by DRW_viewport_data_create(), and workbench_view_layer_data_ensure_ex().
void BLI_memblock_destroy | ( | BLI_memblock * | mblk, |
MemblockValFreeFP | free_callback | ||
) |
Definition at line 66 of file BLI_memblock.c.
References BLI_memblock::chunk_len, BLI_memblock::chunk_list, BLI_memblock::chunk_size, BLI_memblock::elem_last, BLI_memblock::elem_size, MEM_freeN, and MEM_SAFE_FREE.
Referenced by DRW_instance_data_list_free(), DRW_viewport_data_free(), EEVEE_view_layer_data_free(), gpencil_view_layer_data_free(), and workbench_view_layer_data_free().
void* BLI_memblock_elem_get | ( | BLI_memblock * | mblk, |
int | chunk, | ||
int | elem | ||
) |
Direct access. elem is element index inside the chosen chunk. Double usage: You can set chunk to 0 and set the absolute elem index. The correct chunk will be retrieve.
Definition at line 176 of file BLI_memblock.c.
References BLI_assert, BLI_memblock::chunk_list, BLI_memblock::chunk_size, and BLI_memblock::elem_size.
Referenced by DRW_memblock_elem_from_handle(), drw_resource_buffer_finish(), and workbench_material_chunk_select().
void BLI_memblock_iternew | ( | BLI_memblock * | mblk, |
BLI_memblock_iter * | iter | ||
) |
Definition at line 145 of file BLI_memblock.c.
References BLI_memblock_iter::chunk_idx, BLI_memblock_iter::chunk_list, BLI_memblock::chunk_list, BLI_memblock_iter::chunk_max_ofs, BLI_memblock::chunk_max_ofs, BLI_memblock_iter::cur_index, BLI_memblock::elem_next, BLI_memblock_iter::elem_ofs, BLI_memblock_iter::elem_size, BLI_memblock::elem_size, and BLI_memblock_iter::end_index.
Referenced by draw_compute_culling(), draw_texture_release(), DRW_instance_buffer_finish(), drw_resource_buffer_finish(), GPENCIL_cache_finish(), and workbench_update_material_ubos().
void* BLI_memblock_iterstep | ( | BLI_memblock_iter * | iter | ) |
Definition at line 157 of file BLI_memblock.c.
References BLI_memblock_iter::chunk_idx, BLI_memblock_iter::chunk_list, BLI_memblock_iter::chunk_max_ofs, BLI_memblock_iter::cur_index, BLI_memblock_iter::elem_ofs, BLI_memblock_iter::elem_size, BLI_memblock_iter::end_index, NULL, and ptr.
Referenced by draw_compute_culling(), draw_texture_release(), DRW_instance_buffer_finish(), drw_resource_buffer_finish(), GPENCIL_cache_finish(), and workbench_update_material_ubos().