Blender
V3.3
|
Efficient in-memory storage of multiple similar arrays. More...
Go to the source code of this file.
Typedefs | |
typedef struct BArrayState | BArrayState |
typedef struct BArrayStore | BArrayStore |
Functions | |
BArrayStore * | BLI_array_store_create (unsigned int stride, unsigned int chunk_count) |
void | BLI_array_store_destroy (BArrayStore *bs) |
void | BLI_array_store_clear (BArrayStore *bs) |
size_t | BLI_array_store_calc_size_expanded_get (const BArrayStore *bs) |
size_t | BLI_array_store_calc_size_compacted_get (const BArrayStore *bs) |
BArrayState * | BLI_array_store_state_add (BArrayStore *bs, const void *data, size_t data_len, const BArrayState *state_reference) |
void | BLI_array_store_state_remove (BArrayStore *bs, BArrayState *state) |
size_t | BLI_array_store_state_size_get (BArrayState *state) |
void | BLI_array_store_state_data_get (BArrayState *state, void *data) |
void * | BLI_array_store_state_data_get_alloc (BArrayState *state, size_t *r_data_len) |
bool | BLI_array_store_is_valid (BArrayStore *bs) |
Efficient in-memory storage of multiple similar arrays.
Definition in file BLI_array_store.h.
typedef struct BArrayState BArrayState |
Definition at line 1 of file BLI_array_store.h.
typedef struct BArrayStore BArrayStore |
Definition at line 1 of file BLI_array_store.h.
size_t BLI_array_store_calc_size_compacted_get | ( | const BArrayStore * | bs | ) |
Definition at line 1478 of file array_store.c.
References BLI_assert, BLI_mempool_iternew(), BLI_mempool_iterstep(), BArrayMemory::chunk, BChunk::data_len, BArrayStore::memory, and BChunk::users.
Referenced by BLI_array_store_at_size_calc_memory_usage(), random_chunk_mutate_helper(), TEST(), and text_undosys_step_encode_to_state().
size_t BLI_array_store_calc_size_expanded_get | ( | const BArrayStore * | bs | ) |
Find the memory used by all states (expanded & real).
Definition at line 1469 of file array_store.c.
References LISTBASE_FOREACH, state, and BArrayStore::states.
Referenced by BLI_array_store_at_size_calc_memory_usage(), and TEST().
void BLI_array_store_clear | ( | BArrayStore * | bs | ) |
Clear all contents, allowing reuse of bs.
Definition at line 1452 of file array_store.c.
References array_store_free_data(), BLI_listbase_clear(), BLI_mempool_clear(), BArrayMemory::chunk, BArrayMemory::chunk_list, BArrayMemory::chunk_ref, BArrayStore::memory, and BArrayStore::states.
BArrayStore* BLI_array_store_create | ( | unsigned int | stride, |
unsigned int | chunk_count | ||
) |
Create a new array store, which can store any number of arrays as long as their stride matches.
stride | sizeof() each element, |
1
will always work, its less efficient since duplicate chunks of memory will be searched at positions unaligned with the array data.chunk_count | Number of elements to split each chunk into.
|
Definition at line 1388 of file array_store.c.
References BArrayInfo::accum_read_ahead_bytes, BArrayInfo::accum_read_ahead_len, BArrayInfo::accum_steps, BCHUNK_HASH_TABLE_ACCUMULATE_STEPS, BCHUNK_SIZE_MAX_MUL, BCHUNK_SIZE_MIN_DIV, BLI_MEMPOOL_ALLOW_ITER, BLI_mempool_create(), BLI_MEMPOOL_NOP, BArrayMemory::chunk, BArrayInfo::chunk_byte_size, BArrayInfo::chunk_byte_size_max, BArrayInfo::chunk_byte_size_min, BArrayMemory::chunk_list, BArrayMemory::chunk_ref, BArrayInfo::chunk_stride, BArrayStore::info, MAX2, MEM_callocN, BArrayStore::memory, and stride.
Referenced by BLI_array_store_at_size_ensure(), random_chunk_mutate_helper(), TEST(), testbuffer_run_tests_simple(), and text_undosys_step_encode_to_state().
void BLI_array_store_destroy | ( | BArrayStore * | bs | ) |
Free the BArrayStore, including all states and chunks.
Definition at line 1441 of file array_store.c.
References array_store_free_data(), BLI_mempool_destroy(), BArrayMemory::chunk, BArrayMemory::chunk_list, BArrayMemory::chunk_ref, MEM_freeN, and BArrayStore::memory.
Referenced by BLI_array_store_at_size_clear(), random_chunk_mutate_helper(), TEST(), testbuffer_run_tests_simple(), and text_undosys_step_free().
bool BLI_array_store_is_valid | ( | BArrayStore * | bs | ) |
Definition at line 1604 of file array_store.c.
References bchunk_list_size(), BLI_ghash_free(), BLI_ghash_len(), BLI_ghash_ptr_new(), BLI_ghashIterator_getKey(), BLI_ghashIterator_getValue(), BLI_listbase_count(), BLI_mempool_iternew(), BLI_mempool_iterstep(), BLI_mempool_len(), BArrayMemory::chunk, BArrayInfo::chunk_byte_size_min, BArrayMemory::chunk_list, BArrayMemory::chunk_ref, BChunkList::chunk_refs, BChunkList::chunk_refs_len, BTableRef::cref, BChunk::data, BChunk::data_len, GHASH_ITER, GHASH_PTR_ADD_USER, BArrayStore::info, BChunkRef::link, LISTBASE_FOREACH, MEM_allocN_len, BArrayStore::memory, NULL, POINTER_AS_INT, state, BArrayStore::states, BChunkList::total_size, BChunkList::users, BChunk::users, and users.
Referenced by TEST(), and testbuffer_run_tests_single().
BArrayState* BLI_array_store_state_add | ( | BArrayStore * | bs, |
const void * | data, | ||
size_t | data_len, | ||
const BArrayState * | state_reference | ||
) |
data | Data used to create |
state_reference | The state to use as a reference when adding the new state, typically this is the previous state, however it can be any previously created state from this bs. |
Definition at line 1497 of file array_store.c.
References bchunk_list_fill_from_array(), bchunk_list_from_data_merge(), bchunk_list_new(), BLI_addtail(), BLI_array_store_state_data_get_alloc(), BLI_assert, BLI_findindex(), BArrayState::chunk_list, BArrayInfo::chunk_stride, data, BArrayStore::info, MEM_callocN, MEM_freeN, BArrayStore::memory, state, BArrayStore::states, and BChunkList::users.
Referenced by TEST(), testbuffer_list_store_populate(), text_state_encode(), um_arraystore_cd_compact(), and um_arraystore_compact_ex().
void BLI_array_store_state_data_get | ( | BArrayState * | state, |
void * | data | ||
) |
Fill in existing allocated memory with the contents of state.
Definition at line 1562 of file array_store.c.
References BLI_assert, BTableRef::cref, BChunk::data, data, BChunk::data_len, BChunkRef::link, LISTBASE_FOREACH, state, and BChunk::users.
Referenced by BLI_array_store_state_data_get_alloc().
void* BLI_array_store_state_data_get_alloc | ( | BArrayState * | state, |
size_t * | r_data_len | ||
) |
Allocate an array for state and return it.
Definition at line 1580 of file array_store.c.
References BLI_array_store_state_data_get(), data, MEM_mallocN, and state.
Referenced by BLI_array_store_state_add(), TEST(), testbuffer_item_validate(), text_state_decode(), um_arraystore_cd_expand(), and um_arraystore_expand().
void BLI_array_store_state_remove | ( | BArrayStore * | bs, |
BArrayState * | state | ||
) |
Remove a state and free any unused BChunk data.
The states can be freed in any order.
Definition at line 1545 of file array_store.c.
References bchunk_list_decref(), BLI_assert, BLI_findindex(), BLI_remlink(), MEM_freeN, BArrayStore::memory, state, and BArrayStore::states.
Referenced by TEST(), testbuffer_list_store_clear(), text_undosys_step_free(), um_arraystore_cd_free(), and um_arraystore_free().
size_t BLI_array_store_state_size_get | ( | BArrayState * | state | ) |
Definition at line 1557 of file array_store.c.
References state.
Referenced by TEST().