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

Default memory manager class. More...

#include <allocator.h>

Public Member Functions

 DefaultMemoryManager () noexcept
 
 DefaultMemoryManager (const DefaultMemoryManager &) noexcept=default
 
 DefaultMemoryManager (DefaultMemoryManager &&) noexcept=default
 
 ~DefaultMemoryManager () noexcept
 
DefaultMemoryManageroperator= (const DefaultMemoryManager &) noexcept=default
 
DefaultMemoryManageroperator= (DefaultMemoryManager &&) noexcept=default
 
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

Default memory manager class.

Default memory manager uses malloc() and free() system functions to allocate and deallocate memory.

Not thread-safe.

Examples
memory_arena.cpp, and memory_pool.cpp.

Definition at line 186 of file allocator.h.

Constructor & Destructor Documentation

◆ DefaultMemoryManager() [1/3]

CppCommon::DefaultMemoryManager::DefaultMemoryManager ( )
inlinenoexcept

Definition at line 189 of file allocator.h.

◆ DefaultMemoryManager() [2/3]

CppCommon::DefaultMemoryManager::DefaultMemoryManager ( const DefaultMemoryManager )
defaultnoexcept

◆ DefaultMemoryManager() [3/3]

CppCommon::DefaultMemoryManager::DefaultMemoryManager ( DefaultMemoryManager &&  )
defaultnoexcept

◆ ~DefaultMemoryManager()

CppCommon::DefaultMemoryManager::~DefaultMemoryManager ( )
inlinenoexcept

Definition at line 192 of file allocator.h.

Member Function Documentation

◆ allocated()

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

Allocated memory in bytes.

Definition at line 198 of file allocator.h.

◆ allocations()

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

Count of active memory allocations.

Definition at line 200 of file allocator.h.

◆ free()

void CppCommon::DefaultMemoryManager::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 163 of file allocator.inl.

◆ malloc()

void * CppCommon::DefaultMemoryManager::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 148 of file allocator.inl.

◆ max_size()

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

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

Definition at line 203 of file allocator.h.

◆ operator=() [1/2]

DefaultMemoryManager& CppCommon::DefaultMemoryManager::operator= ( const DefaultMemoryManager )
defaultnoexcept

◆ operator=() [2/2]

DefaultMemoryManager& CppCommon::DefaultMemoryManager::operator= ( DefaultMemoryManager &&  )
defaultnoexcept

◆ reset()

void CppCommon::DefaultMemoryManager::reset ( )
inline

Reset the memory manager.

Definition at line 177 of file allocator.inl.


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