9 #ifndef CPPCOMMON_MEMORY_ALLOCATOR_HEAP_H
10 #define CPPCOMMON_MEMORY_ALLOCATOR_HEAP_H
14 #if defined(_WIN32) || defined(_WIN64)
46 size_t allocated() const noexcept {
return _allocated; }
51 size_t max_size() const noexcept {
return std::numeric_limits<size_t>::max(); }
59 void*
malloc(
size_t size,
size_t alignment =
alignof(std::max_align_t));
65 void free(
void* ptr,
size_t size);
77 template <
typename T,
bool nothrow = false>
Memory allocator definition.
Heap memory allocator inline implementation.
Heap memory manager class.
size_t allocated() const noexcept
Allocated memory in bytes.
~HeapMemoryManager() noexcept
void reset()
Reset the memory manager.
HeapMemoryManager & operator=(const HeapMemoryManager &)=delete
HeapMemoryManager() noexcept
size_t max_size() const noexcept
Maximum memory block size, that could be allocated by the memory manager.
void * malloc(size_t size, size_t alignment=alignof(std::max_align_t))
Allocate a new memory block of the given size.
HeapMemoryManager & operator=(HeapMemoryManager &&)=delete
HeapMemoryManager(HeapMemoryManager &&)=delete
HeapMemoryManager(const HeapMemoryManager &)=delete
size_t allocations() const noexcept
Count of active memory allocations.
void free(void *ptr, size_t size)
Free the previously allocated memory block.
C++ Common project definitions.