TRIQS/nda 1.3.0
Multi-dimensional array library for C++
|
#include <nda/mem/allocators.hpp>
Wrap an allocator to check for memory leaks.
It simply keeps track of the memory currently being used by the allocator, i.e. the total memory allocated minus the total memory deallocated, which should never be smaller than zero and should be exactly zero when the allocator is destroyed.
A | nda::mem::Allocator type to wrap. |
Definition at line 464 of file allocators.hpp.
Public Member Functions | |
leak_check ()=default | |
Default constructor. | |
leak_check (leak_check &&)=default | |
Default move constructor. | |
leak_check (leak_check const &)=delete | |
Deleted copy constructor. | |
~leak_check () | |
Destructor that checks for memory leaks. | |
blk_t | allocate (size_t s) |
Allocate memory and update the total memory used. | |
blk_t | allocate_zero (size_t s) |
Allocate memory, set it to zero and update the total memory used. | |
void | deallocate (blk_t b) noexcept |
Deallocate memory and update the total memory used. | |
bool | empty () const |
Check if the base allocator is empty. | |
long | get_memory_used () const noexcept |
Get the total memory used by the base allocator. | |
leak_check & | operator= (leak_check &&)=default |
Default move assignment operator. | |
leak_check & | operator= (leak_check const &)=delete |
Deleted copy assignment operator. | |
bool | owns (blk_t b) const noexcept |
Check if a given nda::mem::blk_t memory block is owned by the base allocator. | |
Static Public Attributes | |
static constexpr auto | address_space = A::address_space |
nda::mem::AddressSpace in which the memory is allocated. | |
|
inline |
Destructor that checks for memory leaks.
In debug mode, it aborts the program if there is a memory leak.
Definition at line 491 of file allocators.hpp.
|
inline |
Allocate memory and update the total memory used.
s | Size in bytes of the memory to allocate. |
Definition at line 506 of file allocators.hpp.
|
inline |
Allocate memory, set it to zero and update the total memory used.
s | Size in bytes of the memory to allocate. |
Definition at line 518 of file allocators.hpp.
|
inlinenoexcept |
Deallocate memory and update the total memory used.
In debug mode, it aborts the program if the total memory used is smaller than zero.
b | nda::mem::blk_t memory block to deallocate. |
Definition at line 529 of file allocators.hpp.
|
inlinenodiscard |
Check if the base allocator is empty.
Definition at line 544 of file allocators.hpp.
|
inlinenodiscardnoexcept |
Get the total memory used by the base allocator.
Definition at line 558 of file allocators.hpp.
|
inlinenodiscardnoexcept |
Check if a given nda::mem::blk_t memory block is owned by the base allocator.
b | nda::mem::blk_t memory block. |
Definition at line 552 of file allocators.hpp.