TRIQS/nda 1.3.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
nda::mem::mallocator< AdrSp >

#include <nda/mem/allocators.hpp>

Detailed Description

template<AddressSpace AdrSp = Host>
class nda::mem::mallocator< AdrSp >

Custom allocator that uses nda::mem::malloc to allocate memory.

Template Parameters
AdrSpnda::mem::AddressSpace in which the memory is allocated.

Definition at line 71 of file allocators.hpp.

Public Member Functions

 mallocator ()=default
 Default constructor.
 
 mallocator (mallocator &&)=default
 Default move constructor.
 
 mallocator (mallocator const &)=delete
 Deleted copy constructor.
 
mallocatoroperator= (mallocator &&)=default
 Default move assignment operator.
 
mallocatoroperator= (mallocator const &)=delete
 Deleted copy assignment operator.
 

Static Public Member Functions

static blk_t allocate (size_t s) noexcept
 Allocate memory using nda::mem::malloc.
 
static blk_t allocate_zero (size_t s) noexcept
 Allocate memory and set it to zero.
 
static void deallocate (blk_t b) noexcept
 Deallocate memory using nda::mem::free.
 

Static Public Attributes

static constexpr auto address_space = AdrSp
 nda::mem::AddressSpace in which the memory is allocated.
 

Member Function Documentation

◆ allocate()

template<AddressSpace AdrSp = Host>
static blk_t nda::mem::mallocator< AdrSp >::allocate ( size_t s)
inlinestaticnoexcept

Allocate memory using nda::mem::malloc.

Parameters
sSize in bytes of the memory to allocate.
Returns
nda::mem::blk_t memory block.

Definition at line 97 of file allocators.hpp.

◆ allocate_zero()

template<AddressSpace AdrSp = Host>
static blk_t nda::mem::mallocator< AdrSp >::allocate_zero ( size_t s)
inlinestaticnoexcept

Allocate memory and set it to zero.

The behavior depends on the address space:

Parameters
sSize in bytes of the memory to allocate.
Returns
nda::mem::blk_t memory block.

Definition at line 109 of file allocators.hpp.

◆ deallocate()

template<AddressSpace AdrSp = Host>
static void nda::mem::mallocator< AdrSp >::deallocate ( blk_t b)
inlinestaticnoexcept

Deallocate memory using nda::mem::free.

Parameters
bnda::mem::blk_t memory block to deallocate.

Definition at line 123 of file allocators.hpp.


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