Documentation of memory

( foonathan/memory)

heap_allocator Class Reference

Detailed Description

A stateless RawAllocator that allocates memory from the heap.

It uses the two functions heap_alloc and heap_dealloc for the allocation, which default to std::malloc and std::free.

Typedefs

using is_stateful = std::false_type
 

Member Functions

 heap_allocator (heap_allocator &&) noexcept
 
heap_allocatoroperator= (heap_allocator &&) noexcept
 
void * allocate_node (std::size_t size, std::size_t alignment)
 
void deallocate_node (void *ptr, std::size_t size, std::size_t alignment) noexcept
 
std::size_t max_node_size () const noexcept
 

Member Functions

void* allocate_node ( std::size_t  size,
std::size_t  alignment 
)
Effects:
A RawAllocator allocation function. It uses heap_alloc.
Returns:
A pointer to a node, it will never be nullptr.
Throws:
An exception of type out_of_memory or whatever is thrown by its handler if heap_alloc returns a nullptr.
void deallocate_node ( void *  ptr,
std::size_t  size,
std::size_t  alignment 
)
noexcept
Effects:
A RawAllocator deallocation function. It uses heap_dealloc.
std::size_t max_node_size ( ) const
noexcept
Returns:
The maximum node size by forwaring to std::allocator<char>::max_size() or the maximum value on a freestanding implementation.