Pyrogenesis
13997
|
(header-less) pool-based heap allocator provides Allocate and Deallocate without requiring in-band headers; this is useful when allocating page-aligned I/O buffers (headers would waste an entire page per buffer) More...
#include <headerless.h>
Classes | |
class | Impl |
Public Member Functions | |
HeaderlessAllocator (size_t poolSize) | |
void | Reset () |
restore the original state (as if newly constructed). More... | |
NOTHROW_DECLARE void * | Allocate (size_t size) |
void | Deallocate (void *p, size_t size) |
deallocate memory. More... | |
void | Validate () const |
perform sanity checks; ensure allocator state is consistent. More... | |
Static Public Attributes | |
static const size_t | allocationAlignment = 16 |
static const size_t | minAllocationSize = 128 |
Private Attributes | |
shared_ptr< Impl > | impl |
(header-less) pool-based heap allocator provides Allocate and Deallocate without requiring in-band headers; this is useful when allocating page-aligned I/O buffers (headers would waste an entire page per buffer)
policy:
note: this module basically implements a (rather complex) freelist and could be made independent of the Pool allocation scheme. however, reading neighboring boundary tags may cause segmentation violations; knowing the bounds of valid committed memory (i.e. Pool extents) avoids this.
Definition at line 49 of file headerless.h.
HeaderlessAllocator::HeaderlessAllocator | ( | size_t | poolSize | ) |
poolSize | maximum amount of memory that can be allocated. this much virtual address space is reserved up-front (see Pool). |
Definition at line 747 of file headerless.cpp.
NOTHROW_DEFINE void * HeaderlessAllocator::Allocate | ( | size_t | size | ) |
size | [bytes] (= minAllocationSize + i*allocationAlignment). (this allocator is designed for requests on the order of several KiB) |
Definition at line 757 of file headerless.cpp.
void HeaderlessAllocator::Deallocate | ( | void * | p, |
size_t | size | ||
) |
deallocate memory.
p | must be exactly as returned by Allocate (in particular, evenly divisible by allocationAlignment) |
size | must be exactly as specified to Allocate. |
Definition at line 762 of file headerless.cpp.
void HeaderlessAllocator::Reset | ( | ) |
restore the original state (as if newly constructed).
this includes reclaiming all extant allocations.
Definition at line 752 of file headerless.cpp.
void HeaderlessAllocator::Validate | ( | ) | const |
perform sanity checks; ensure allocator state is consistent.
Definition at line 767 of file headerless.cpp.
|
static |
Definition at line 56 of file headerless.h.
|
private |
Definition at line 95 of file headerless.h.
|
static |
Definition at line 60 of file headerless.h.