VAE - Virtual Audio Engine 1
Small Data Driven Audio Engine
tklb::StdAllocator< T > Struct Template Reference

#include <TAllocator.hpp>

Inheritance diagram for tklb::StdAllocator< T >:
Collaboration diagram for tklb::StdAllocator< T >:

Public Types

typedef T value_type
 

Public Member Functions

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

Detailed Description

template<class T>
struct tklb::StdAllocator< T >

Definition at line 17 of file TAllocator.hpp.

Member Typedef Documentation

◆ value_type

template<class T >
typedef T tklb::StdAllocator< T >::value_type

Definition at line 18 of file TAllocator.hpp.

Constructor & Destructor Documentation

◆ StdAllocator() [1/3]

template<class T >
tklb::StdAllocator< T >::StdAllocator ( )
default

◆ StdAllocator() [2/3]

template<class T >
tklb::StdAllocator< T >::StdAllocator ( const StdAllocator< T > &  )
default

◆ StdAllocator() [3/3]

template<class T >
template<class U >
tklb::StdAllocator< T >::StdAllocator ( const StdAllocator< U > &  )
inline

Definition at line 23 of file TAllocator.hpp.

23{ }

Member Function Documentation

◆ allocate()

template<class T >
T * tklb::StdAllocator< T >::allocate ( size_t  n)
inlinenoexcept

Definition at line 25 of file TAllocator.hpp.

25 {
26 if (n > std::numeric_limits<size_t>::max() / sizeof(T)) {
27 return nullptr;
28 }
29 const auto bytes = n * sizeof(T);
30 if (auto ptr = static_cast<T*>(malloc(bytes))) {
31 TKLB_TRACK_ALLOCATE(ptr, bytes);
32 return ptr;
33 }
34
35 return nullptr;
36 }
#define TKLB_TRACK_ALLOCATE(ptr, size)
Definition: TAllocator.hpp:11
#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
Here is the call graph for this function:

◆ deallocate()

template<class T >
void tklb::StdAllocator< T >::deallocate ( T *  ptr,
size_t  n 
)
inlinenoexcept

Definition at line 38 of file TAllocator.hpp.

38 {
39 TKLB_TRACK_FREE(ptr, sizeof(T) * n);
40 free(ptr);
41 }
#define TKLB_TRACK_FREE(ptr, size)
Definition: TAllocator.hpp:12
#define free(ptr)

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