CppCommon  1.0.4.1
C++ Common Library
Public Member Functions | List of all members
CppCommon::NullMemoryManager Class Reference

Null memory manager class. More...

#include <allocator_null.h>

Public Member Functions

 NullMemoryManager () noexcept
 
 NullMemoryManager (const NullMemoryManager &)=delete
 
 NullMemoryManager (NullMemoryManager &&)=delete
 
 ~NullMemoryManager () noexcept
 
NullMemoryManageroperator= (const NullMemoryManager &)=delete
 
NullMemoryManageroperator= (NullMemoryManager &&)=delete
 
size_t allocated () const noexcept
 Allocated memory in bytes. More...
 
size_t allocations () const noexcept
 Count of active memory allocations. More...
 
size_t max_size () const noexcept
 Maximum memory block size, that could be allocated by the memory manager. More...
 
void * malloc (size_t size, size_t alignment=alignof(std::max_align_t))
 Allocate a new memory block of the given size. More...
 
void free (void *ptr, size_t size)
 Free the previously allocated memory block. More...
 
void reset ()
 Reset the memory manager. More...
 

Detailed Description

Null memory manager class.

Null memory manager will always return nullptr for any attempt to allocate a memory buffer of the given size.

Not thread-safe.

Definition at line 23 of file allocator_null.h.

Constructor & Destructor Documentation

◆ NullMemoryManager() [1/3]

CppCommon::NullMemoryManager::NullMemoryManager ( )
inlinenoexcept

Definition at line 26 of file allocator_null.h.

◆ NullMemoryManager() [2/3]

CppCommon::NullMemoryManager::NullMemoryManager ( const NullMemoryManager )
delete

◆ NullMemoryManager() [3/3]

CppCommon::NullMemoryManager::NullMemoryManager ( NullMemoryManager &&  )
delete

◆ ~NullMemoryManager()

CppCommon::NullMemoryManager::~NullMemoryManager ( )
inlinenoexcept

Definition at line 29 of file allocator_null.h.

Member Function Documentation

◆ allocated()

size_t CppCommon::NullMemoryManager::allocated ( ) const
inlinenoexcept

Allocated memory in bytes.

Definition at line 35 of file allocator_null.h.

◆ allocations()

size_t CppCommon::NullMemoryManager::allocations ( ) const
inlinenoexcept

Count of active memory allocations.

Definition at line 37 of file allocator_null.h.

◆ free()

void CppCommon::NullMemoryManager::free ( void *  ptr,
size_t  size 
)
inline

Free the previously allocated memory block.

Parameters
ptr- Pointer to the memory block
size- Block size

Definition at line 20 of file allocator_null.inl.

◆ malloc()

void * CppCommon::NullMemoryManager::malloc ( size_t  size,
size_t  alignment = alignof(std::max_align_t) 
)
inline

Allocate a new memory block of the given size.

Parameters
size- Block size
alignment- Block alignment (default is alignof(std::max_align_t))
Returns
A pointer to the allocated memory block or nullptr in case of allocation failed

Definition at line 11 of file allocator_null.inl.

◆ max_size()

size_t CppCommon::NullMemoryManager::max_size ( ) const
inlinenoexcept

Maximum memory block size, that could be allocated by the memory manager.

Definition at line 40 of file allocator_null.h.

◆ operator=() [1/2]

NullMemoryManager& CppCommon::NullMemoryManager::operator= ( const NullMemoryManager )
delete

◆ operator=() [2/2]

NullMemoryManager& CppCommon::NullMemoryManager::operator= ( NullMemoryManager &&  )
delete

◆ reset()

void CppCommon::NullMemoryManager::reset ( )
inline

Reset the memory manager.

Definition at line 32 of file allocator_null.inl.


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