|
Blender V4.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 (const 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 16 of file BLI_array_store.h.
| typedef struct BArrayStore BArrayStore |
Definition at line 17 of file BLI_array_store.h.
| size_t BLI_array_store_calc_size_compacted_get | ( | const BArrayStore * | bs | ) |
Definition at line 1608 of file array_store.cc.
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(), TEST(), 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 1599 of file array_store.cc.
References LISTBASE_FOREACH, state, and BArrayStore::states.
Referenced by BLI_array_store_at_size_calc_memory_usage(), TEST(), and TEST().
| void BLI_array_store_clear | ( | BArrayStore * | bs | ) |
Clear all contents, allowing reuse of bs.
Definition at line 1582 of file array_store.cc.
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 1494 of file array_store.cc.
References BArrayInfo::accum_read_ahead_bytes, BArrayInfo::accum_read_ahead_len, BArrayInfo::accum_steps, BCHUNK_HASH_TABLE_ACCUMULATE_STEPS_16BITS, BCHUNK_HASH_TABLE_ACCUMULATE_STEPS_32BITS, BCHUNK_HASH_TABLE_ACCUMULATE_STEPS_8BITS, BCHUNK_HASH_TABLE_ACCUMULATE_STEPS_DEFAULT, BCHUNK_SIZE_MAX_MUL, BCHUNK_SIZE_MIN_DIV, BLI_assert, 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, BArrayStore::memory, and UNLIKELY.
Referenced by BLI_array_store_at_size_ensure(), random_chunk_mutate_helper(), TEST(), TEST(), TEST(), TEST(), TEST(), 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 1571 of file array_store.cc.
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(), TEST(), TEST(), TEST(), TEST(), TEST(), testbuffer_run_tests_simple(), and text_undosys_step_free().
| bool BLI_array_store_is_valid | ( | BArrayStore * | bs | ) |
Definition at line 1734 of file array_store.cc.
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, BChunk::data, BChunk::data_len, GHASH_ITER, GHASH_PTR_ADD_USER, BArrayStore::info, BChunkRef::link, LISTBASE_FOREACH, MEM_allocN_len, BArrayStore::memory, POINTER_AS_INT, state, BArrayStore::states, BChunkList::total_expanded_size, BChunk::users, BChunkList::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 1627 of file array_store.cc.
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, BArrayStore::info, MEM_freeN(), BArrayStore::memory, state, BArrayStore::states, and BChunkList::users.
Referenced by TEST(), TEST(), TEST(), TEST(), testbuffer_list_store_populate(), text_state_encode(), and um_arraystore_cd_compact().
| void BLI_array_store_state_data_get | ( | const BArrayState * | state, |
| void * | data ) |
Fill in existing allocated memory with the contents of state.
Definition at line 1692 of file array_store.cc.
References BLI_assert, BChunk::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 1710 of file array_store.cc.
References BLI_array_store_state_data_get(), data, MEM_mallocN, and state.
Referenced by BLI_array_store_state_add(), TEST(), TEST(), 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 1675 of file array_store.cc.
References bchunk_list_decref(), BLI_assert, BLI_findindex(), BLI_remlink(), BArrayMemory::chunk_list, 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 1687 of file array_store.cc.
References state.
Referenced by TEST().