The OpenD Programming Language

FreeList.allocate

Allocates memory either off of the free list or from the parent allocator. If n is within [min, max] or if the free list is unchecked (minSize == 0 && maxSize == size_t.max), then the free list is consulted first. If not empty (hit), the block at the front of the free list is removed from the list and returned. Otherwise (miss), a new block of max bytes is allocated, truncated to n bytes, and returned.

struct FreeList(ParentAllocator, size_t minSize, size_t maxSize = minSize, Flag!"adaptive" adaptive = No.adaptive)
void[]
allocate
(
size_t n
)

Parameters

n size_t

number of bytes to allocate

Return Value

Type: void[]

The allocated block, or null.

Precondition: If set at runtime, min and/or max must be initialized appropriately.

Postcondition: result.length == bytes || result is null

Meta