|
Blender V5.0
|
#include <BLI_linear_allocator.hh>
Inherits blender::NonCopyable, and blender::NonMovable.
Inherited by blender::index_mask::IndexMaskMemory.
Public Member Functions | |
| LinearAllocator () | |
| ~LinearAllocator () | |
| void * | allocate (const int64_t size, const int64_t alignment) |
| template<typename T> | |
| T * | allocate () |
| void * | allocate (const CPPType &type) |
| template<typename T> | |
| MutableSpan< T > | allocate_array (int64_t size) |
| void * | allocate_array (const CPPType &type, const int64_t size) |
| template<typename T, typename... Args> | |
| destruct_ptr< T > | construct (Args &&...args) |
| template<typename T, typename... Args> | |
| MutableSpan< T > | construct_array (int64_t size, Args &&...args) |
| template<typename T> | |
| MutableSpan< T > | construct_array_copy (Span< T > src) |
| StringRefNull | copy_string (StringRef str) |
| MutableSpan< void * > | allocate_elements_and_pointer_array (int64_t element_amount, int64_t element_size, int64_t element_alignment) |
| template<typename T, typename... Args> | |
| Span< T * > | construct_elements_and_pointer_array (int64_t n, Args &&...args) |
| void | provide_buffer (void *buffer, const int64_t size) |
| template<size_t Size, size_t Alignment> | |
| void | provide_buffer (AlignedBuffer< Size, Alignment > &aligned_buffer) |
| void | free_end_of_previous_allocation (const int64_t original_allocation_size, const void *free_after) |
| void | transfer_ownership_from (LinearAllocator<> &other) |
If enabled, LinearAllocator keeps track of how much memory it owns and how much it has allocated. A linear allocator is the simplest form of an allocator. It never reuses any memory, and therefore does not need a deallocation method. It simply hands out consecutive buffers of memory. When the current buffer is full, it allocates a new larger buffer and continues.
Definition at line 29 of file BLI_linear_allocator.hh.
|
inline |
Definition at line 47 of file BLI_linear_allocator.hh.
Referenced by transfer_ownership_from().
|
inline |
Definition at line 53 of file BLI_linear_allocator.hh.
References ptr.
|
inline |
Allocate a memory buffer that can hold an instance of T.
This method only allocates memory and does not construct the instance.
Definition at line 99 of file BLI_linear_allocator.hh.
References allocate(), and T.
Referenced by allocate(), allocate(), allocate(), allocate_array(), allocate_array(), allocate_elements_and_pointer_array(), construct(), and copy_string().
|
inline |
Same as above but uses a runtime CPPType.
Definition at line 105 of file BLI_linear_allocator.hh.
References blender::CPPType::alignment, allocate(), and blender::CPPType::size.
|
inline |
Get a pointer to a memory buffer with the given size an alignment. The memory buffer will be freed when this LinearAllocator is destructed.
The alignment has to be a power of 2.
Definition at line 66 of file BLI_linear_allocator.hh.
References allocate(), BLI_assert, and size().
Referenced by blender::nodes::evaluate_closure_eagerly(), blender::fn::lazy_function::Executor::execute(), blender::nodes::execute_geometry_nodes_on_geometry(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), and blender::tests::TEST().
|
inline |
Same as above but uses a runtime CPPType.
Definition at line 122 of file BLI_linear_allocator.hh.
References blender::CPPType::alignment, allocate(), blender::CPPType::size, and size().
|
inline |
Allocate a memory buffer that can hold T array with the given size.
This method only allocates memory and does not construct the instance.
Definition at line 115 of file BLI_linear_allocator.hh.
References allocate(), size(), and T.
Referenced by construct_array(), construct_array_copy(), blender::index_mask::evaluate_exact_with_indices(), blender::fn::evaluate_fields(), blender::index_mask::IndexMask::from_repeating(), blender::index_mask::IndexMask::from_segments(), blender::index_mask::get_every_nth_index(), blender::index_mask::segments_from_batch_predicate(), blender::index_mask::segments_from_indices(), blender::index_mask::IndexMask::shift(), blender::tests::TEST(), blender::tests::TEST(), and blender::csv_parse::unescape_field().
|
inline |
Definition at line 182 of file BLI_linear_allocator.hh.
References allocate(), i, and POINTER_OFFSET.
Referenced by construct_elements_and_pointer_array().
|
inline |
Construct an instance of T in memory provided by this allocator.
Arguments passed to this method will be forwarded to the constructor of T.
You must not call delete on the returned value. Instead, only the destructor has to be called.
Definition at line 135 of file BLI_linear_allocator.hh.
References allocate(), and T.
Referenced by blender::linear_allocator::ChunkedList< T, SegmentCapacity >::append_as(), blender::nodes::evaluate_closure_eagerly(), blender::nodes::LazyFunctionForViewerNode::execute_impl(), blender::nodes::GeoNodesUserData::get_local(), blender::nodes::geo_eval_log::GeoNodesLog::get_local_tree_logger(), blender::fn::lazy_function::GraphExecutor::init_storage(), blender::nodes::LazyFunctionForEvaluateClosureNode::init_storage(), blender::nodes::LazyFunctionForForeachGeometryElementZone::init_storage(), blender::nodes::LazyFunctionForGroupNode::init_storage(), blender::nodes::LazyFunctionForRepeatZone::init_storage(), and blender::tests::TEST().
|
inline |
Construct multiple instances of a type in an array. The constructor of is called with the given arguments. The caller is responsible for calling the destructor (and not delete) on the constructed elements.
Definition at line 148 of file BLI_linear_allocator.hh.
References allocate_array(), i, size(), and T.
Referenced by blender::tests::TEST().
|
inline |
Copy the given array into a memory buffer provided by this allocator.
Definition at line 160 of file BLI_linear_allocator.hh.
References allocate_array(), blender::MutableSpan< T >::data(), blender::Span< T >::data(), blender::Span< T >::is_empty(), blender::Span< T >::size(), and blender::uninitialized_copy_n().
Referenced by blender::index_mask::bits_to_indices(), blender::index_mask::detail::segments_from_predicate_filter(), and blender::tests::TEST().
|
inline |
Definition at line 200 of file BLI_linear_allocator.hh.
References allocate_elements_and_pointer_array(), blender::MutableSpan< T >::cast(), i, and T.
Referenced by blender::tests::TEST().
|
inline |
Copy the given string into a memory buffer provided by this allocator. The returned string is always null terminated.
Definition at line 174 of file BLI_linear_allocator.hh.
References allocate(), and str.
Referenced by blender::io::fbx::create_transform_curve_desc(), blender::string_search::extract_normalized_words(), menu_items_from_all_operators(), menu_items_from_ui_create(), menu_items_from_ui_create_item_from_button(), rna_def_node_item_array_common_functions(), rna_def_node_item_array_new_with_socket_and_name(), rna_def_node_item_array_socket_item_common(), blender::nodes::geo_eval_log::StringLog::StringLog(), and blender::tests::TEST().
|
inline |
Some algorithms can be implemented more efficiently by over-allocating the destination memory a bit. This allows the algorithm not to worry about having enough memory. Generally, this can be a useful strategy if the actual required memory is not known in advance, but an upper bound can be found. Ideally, one can free the over-allocated memory in the end again to reduce memory consumption.
A linear allocator generally does allow freeing any memory. However, there is one exception. One can free the end of the last allocation (but not any previous allocation). While uses of this approach are quite limited, it's still the best option in some situations.
Definition at line 241 of file BLI_linear_allocator.hh.
References BLI_assert.
Referenced by blender::index_mask::evaluate_exact_with_indices().
|
inline |
Definition at line 225 of file BLI_linear_allocator.hh.
References provide_buffer(), and blender::AlignedBuffer< Size, Alignment >::ptr().
|
inline |
Tell the allocator to use up the given memory buffer, before allocating new memory from the system.
Definition at line 217 of file BLI_linear_allocator.hh.
References BLI_assert, and size().
Referenced by blender::index_mask::IndexMaskMemory::IndexMaskMemory(), blender::nodes::socket_usage_inference::infer_group_interface_inputs_usage(), provide_buffer(), blender::tests::TEST(), and blender::tests::TEST().
|
inline |
This allocator takes ownership of the buffers owned by other. Therefor, when other is destructed, memory allocated using it is not freed.
Note that the caller is responsible for making sure that buffers passed into provide_buffer of other live at least as long as this allocator.
Definition at line 269 of file BLI_linear_allocator.hh.
References Vector< T, InlineBufferCapacity, Allocator >::clear(), and LinearAllocator().
Referenced by blender::index_mask::evaluate_short_unknown_segments_exactly(), blender::index_mask::ParallelSegmentsCollector::reduce(), and blender::tests::TEST().