Blender  V3.3
Public Member Functions | List of all members
blender::LinearAllocator< Allocator > Class Template Reference

#include <BLI_linear_allocator.hh>

Inheritance diagram for blender::LinearAllocator< Allocator >:
blender::NonCopyable blender::NonMovable

Public Member Functions

 LinearAllocator ()
 
 ~LinearAllocator ()
 
voidallocate (const int64_t size, const int64_t alignment)
 
template<typename T >
Tallocate ()
 
template<typename T >
MutableSpan< Tallocate_array (int64_t size)
 
template<typename T , typename... Args>
destruct_ptr< Tconstruct (Args &&...args)
 
template<typename T , typename... Args>
MutableSpan< Tconstruct_array (int64_t size, Args &&...args)
 
template<typename T >
MutableSpan< Tconstruct_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, uint size)
 
template<size_t Size, size_t Alignment>
void provide_buffer (AlignedBuffer< Size, Alignment > &aligned_buffer)
 

Detailed Description

template<typename Allocator = GuardedAllocator>
class blender::LinearAllocator< Allocator >

Definition at line 19 of file BLI_linear_allocator.hh.

Constructor & Destructor Documentation

◆ LinearAllocator()

template<typename Allocator = GuardedAllocator>
blender::LinearAllocator< Allocator >::LinearAllocator ( )
inline

Definition at line 37 of file BLI_linear_allocator.hh.

◆ ~LinearAllocator()

template<typename Allocator = GuardedAllocator>
blender::LinearAllocator< Allocator >::~LinearAllocator ( )
inline

Definition at line 43 of file BLI_linear_allocator.hh.

References ptr.

Member Function Documentation

◆ allocate() [1/2]

template<typename Allocator = GuardedAllocator>
template<typename T >
T* blender::LinearAllocator< Allocator >::allocate ( )
inline

◆ allocate() [2/2]

template<typename Allocator = GuardedAllocator>
void* blender::LinearAllocator< Allocator >::allocate ( const int64_t  size,
const int64_t  alignment 
)
inline

◆ allocate_array()

template<typename Allocator = GuardedAllocator>
template<typename T >
MutableSpan<T> blender::LinearAllocator< Allocator >::allocate_array ( int64_t  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 96 of file BLI_linear_allocator.hh.

References blender::LinearAllocator< Allocator >::allocate(), size(), and T.

Referenced by blender::fn::MFProcedure::new_call_instruction(), and blender::tests::TEST().

◆ allocate_elements_and_pointer_array()

template<typename Allocator = GuardedAllocator>
MutableSpan<void *> blender::LinearAllocator< Allocator >::allocate_elements_and_pointer_array ( int64_t  element_amount,
int64_t  element_size,
int64_t  element_alignment 
)
inline

◆ construct()

template<typename Allocator = GuardedAllocator>
template<typename T , typename... Args>
destruct_ptr<T> blender::LinearAllocator< Allocator >::construct ( Args &&...  args)
inline

◆ construct_array()

template<typename Allocator = GuardedAllocator>
template<typename T , typename... Args>
MutableSpan<T> blender::LinearAllocator< Allocator >::construct_array ( int64_t  size,
Args &&...  args 
)
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 123 of file BLI_linear_allocator.hh.

References size(), and T.

Referenced by blender::modifiers::geometry_nodes::GeometryNodesEvaluator::initialize_node_state(), and blender::tests::TEST().

◆ construct_array_copy()

template<typename Allocator = GuardedAllocator>
template<typename T >
MutableSpan<T> blender::LinearAllocator< Allocator >::construct_array_copy ( Span< T src)
inline

Copy the given array into a memory buffer provided by this allocator.

Definition at line 135 of file BLI_linear_allocator.hh.

References blender::MutableSpan< T >::data(), src, and blender::uninitialized_copy_n().

Referenced by BLI_string_search_add(), and blender::tests::TEST().

◆ construct_elements_and_pointer_array()

template<typename Allocator = GuardedAllocator>
template<typename T , typename... Args>
Span<T *> blender::LinearAllocator< Allocator >::construct_elements_and_pointer_array ( int64_t  n,
Args &&...  args 
)
inline

◆ copy_string()

template<typename Allocator = GuardedAllocator>
StringRefNull blender::LinearAllocator< Allocator >::copy_string ( StringRef  str)
inline

Copy the given string into a memory buffer provided by this allocator. The returned string is always null terminated.

Definition at line 149 of file BLI_linear_allocator.hh.

References blender::LinearAllocator< Allocator >::allocate(), buffer, and str.

Referenced by blender::string_search::extract_normalized_words(), and blender::tests::TEST().

◆ provide_buffer() [1/2]

template<typename Allocator = GuardedAllocator>
template<size_t Size, size_t Alignment>
void blender::LinearAllocator< Allocator >::provide_buffer ( AlignedBuffer< Size, Alignment > &  aligned_buffer)
inline

◆ provide_buffer() [2/2]

template<typename Allocator = GuardedAllocator>
void blender::LinearAllocator< Allocator >::provide_buffer ( void buffer,
uint  size 
)
inline

Tell the allocator to use up the given memory buffer, before allocating new memory from the system.

Definition at line 192 of file BLI_linear_allocator.hh.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), buffer, and size().

Referenced by blender::fn::MFProcedureExecutor::call(), blender::LinearAllocator< Allocator >::provide_buffer(), and blender::tests::TEST().


The documentation for this class was generated from the following file: