VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
vae::core::memory::Allocator< T, NAME > Struct Template Reference

Allocator used for all heapbuffers in VAE. More...

#include <vae_allocators.hpp>

Collaboration diagram for vae::core::memory::Allocator< T, NAME >:

Public Types

typedef T value_type
 

Public Member Functions

 Allocator ()=default
 
 Allocator (const Allocator &)=default
 
template<class U , class J >
 Allocator (const Allocator< U, J > &)
 
T * allocate (size_t n) noexcept
 
void deallocate (T *ptr, std::size_t n) noexcept
 

Detailed Description

template<class T, class NAME>
struct vae::core::memory::Allocator< T, NAME >

Allocator used for all heapbuffers in VAE.

Template Parameters
T

Definition at line 17 of file vae_allocators.hpp.

Member Typedef Documentation

◆ value_type

template<class T , class NAME >
typedef T vae::core::memory::Allocator< T, NAME >::value_type

Definition at line 18 of file vae_allocators.hpp.

Constructor & Destructor Documentation

◆ Allocator() [1/3]

template<class T , class NAME >
vae::core::memory::Allocator< T, NAME >::Allocator ( )
default

◆ Allocator() [2/3]

template<class T , class NAME >
vae::core::memory::Allocator< T, NAME >::Allocator ( const Allocator< T, NAME > &  )
default

◆ Allocator() [3/3]

template<class T , class NAME >
template<class U , class J >
vae::core::memory::Allocator< T, NAME >::Allocator ( const Allocator< U, J > &  )
inline

Definition at line 23 of file vae_allocators.hpp.

23{ }

Member Function Documentation

◆ allocate()

template<class T , class NAME >
T * vae::core::memory::Allocator< T, NAME >::allocate ( size_t  n)
inlinenoexcept

Definition at line 25 of file vae_allocators.hpp.

25 {
26 if (n > std::numeric_limits<std::size_t>::max() / sizeof(T)) {
27 return nullptr;
28 }
29
30 if (auto ptr = static_cast<T*>(malloc(n * sizeof(T)))) {
31 VAE_PROFILER_MALLOC_L(ptr, n * sizeof(T), NAME::name)
32 return ptr;
33 }
34
35 return nullptr;
36 }
#define malloc(size)
Force all other standart allocation operators to use the ones provided by tklb.
T max(const T &v1, const T &v2)
Definition: TMath.hpp:21
#define VAE_PROFILER_MALLOC_L(ptr, size, name)
Track named allocaions.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deallocate()

template<class T , class NAME >
void vae::core::memory::Allocator< T, NAME >::deallocate ( T *  ptr,
std::size_t  n 
)
inlinenoexcept

Definition at line 38 of file vae_allocators.hpp.

38 {
39 VAE_PROFILER_FREE_L(ptr, NAME::name)
40 free(ptr);
41 }
#define free(ptr)
#define VAE_PROFILER_FREE_L(ptr, name)
Track named allocaions.
Here is the caller graph for this function:

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