|
memory
|
Macros | |
| #define | FOONATHAN_MEMORY_TEMPORARY_STACK_MODE |
| The mode of the automatic foonathan::memory::temporary_stack creation. | |
Typedefs | |
| using | default_allocator = implementation_defined |
| The default RawAllocator that will be used as BlockAllocator in memory arenas. | |
| using | heap_allocator = implementation_defined |
| A stateless RawAllocator that allocates memory from the heap. | |
| using | malloc_allocator = implementation_defined |
A stateless RawAllocator that allocates memory using std::malloc(). | |
| using | new_allocator = implementation_defined |
A stateless RawAllocator that allocates memory using (nothrow) operator new. | |
Functions | |
| void * | heap_alloc (std::size_t size) noexcept |
| Allocates heap memory. | |
| void | heap_dealloc (void *ptr, std::size_t size) noexcept |
| Deallocates heap memory. | |
| std::size_t | get_virtual_memory_page_size () noexcept |
| void * | virtual_memory_reserve (std::size_t no_pages) noexcept |
| Reserves virtual memory. | |
| void | virtual_memory_release (void *pages, std::size_t no_pages) noexcept |
| Releases reserved virtual memory. | |
| void * | virtual_memory_commit (void *memory, std::size_t no_pages) noexcept |
| Commits reserved virtual memory. | |
| void | virtual_memory_decommit (void *memory, std::size_t no_pages) noexcept |
| Decommits commited virtual memory. | |
Variables | |
| const std::size_t | virtual_memory_page_size |
| The page size of the virtual memory. | |
| template<typename T , class RawAllocator , typename... Args> | |
| auto | allocate_joint (RawAllocator &alloc, joint_size additional_size, Args &&... args) -> joint_ptr< T, RawAllocator > |
| template<typename T , class RawAllocator , typename... Args> | |
| auto | allocate_joint (const RawAllocator &alloc, joint_size additional_size, Args &&... args) -> joint_ptr< T, RawAllocator > |
| template<class RawAllocator , typename T > | |
| auto | clone_joint (RawAllocator &alloc, const joint_type< T > &joint) -> joint_ptr< T, RawAllocator > |
| template<class RawAllocator , typename T > | |
| auto | clone_joint (const RawAllocator &alloc, const joint_type< T > &joint) -> joint_ptr< T, RawAllocator > |
| #define FOONATHAN_MEMORY_TEMPORARY_STACK_MODE |
The mode of the automatic foonathan::memory::temporary_stack creation.
Set to 2 to enable automatic lifetime management of the per-thread stack through nifty counter. Then all memory will be freed upon program termination automatically. Set to 1 to disable automatic lifetime managment of the per-thread stack, requires managing it through the foonathan::memory::temporary_stack_initializer. Set to 0 to disable the per-thread stack completely. foonathan::memory::get_temporary_stack() will abort the program upon call.
The default RawAllocator that will be used as BlockAllocator in memory arenas.
Arena allocators like memory_stack or memory_pool allocate memory by subdividing a huge block. They get a BlockAllocator that will be used for their internal allocation, this type is the default value.
FOONATHAN_MEMORY_DEFAULT_ALLOCATOR, but it must be one of the following: heap_allocator, new_allocator, malloc_allocator, static_allocator, virtual_memory_allocator. 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.
A stateless RawAllocator that allocates memory using std::malloc().
It throws out_of_memory when the allocation fails.
A stateless RawAllocator that allocates memory using (nothrow) operator new.
If the operator returns nullptr, it behaves like new and loops calling std::new_handler, but instead of throwing a std::bad_alloc exception, it throws out_of_memory.
|
noexcept |
Allocates heap memory.
This function is used by the heap_allocator to allocate the heap memory. It is not defined on a freestanding implementation, a definition must be provided by the library user.
max_align_t and has the given size. The size parameter will not be zero. It shall return a nullptr if no memory is available. It must be thread safe. std::malloc is used as fallback. Deallocates heap memory.
This function is used by the heap_allocator to allocate the heap memory. It is not defined on a freestanding implementation, a definition must be provided by the library user.
std::free is used as fallback. | auto allocate_joint | ( | RawAllocator & | alloc, |
| joint_size | additional_size, | ||
| Args &&... | args | ||
| ) | -> joint_ptr<T, RawAllocator> |
| auto clone_joint | ( | RawAllocator & | alloc, |
| const joint_type< T > & | joint | ||
| ) | -> joint_ptr<T, RawAllocator> |
joint. It will allocate as much memory as needed and forward to the copy constructor.
|
noexcept |
|
noexcept |
Reserves virtual memory.
nullptr in case of error. Releases reserved virtual memory.
pages must come from a previous call to virtual_memory_reserve with the same calc_no_pages, it must not be nullptr. Commits reserved virtual memory.
calc_no_pages pages starting at the given address available for use. memory, or nullptr in case of error. Decommits commited virtual memory.
memory must come from a previous call to virtual_memory_commit with the same calc_no_pages it must not be nullptr. | auto allocate_joint | ( | const RawAllocator & | alloc, |
| joint_size | additional_size, | ||
| Args &&... | args | ||
| ) | -> joint_ptr<T, RawAllocator> |
| auto clone_joint | ( | const RawAllocator & | alloc, |
| const joint_type< T > & | joint | ||
| ) | -> joint_ptr<T, RawAllocator> |
joint. It will allocate as much memory as needed and forward to the copy constructor.
|
extern |
The page size of the virtual memory.
All virtual memory allocations must be multiple of this size. It is usually 4KiB.
1.9.8