NodeAllocator

Allocator used for allocating nodes of a fixed size.

template NodeAllocator (
size_t nodeSize
size_t blockSize = 1024
) {}

Members

Aliases

NodeAllocator
alias NodeAllocator = Freelist!(BlockAllocator!(blockSize), ns, ns)
Undocumented in source.

Manifest constants

ns
enum ns;
Undocumented in source.

Examples

enum testSize = 4_000;
static struct Node { Node* next; int payload; }
NodeAllocator!(Node.sizeof, 2048) nodeAllocator;
Node*[testSize] nodes;
foreach (i; 0 .. testSize)
	nodes[i] = allocate!Node(nodeAllocator);
foreach (i; 0 .. testSize)
	assert (nodes[i] !is null);
foreach (i; 0 .. testSize)
	deallocate(nodeAllocator, nodes[i]);

Meta