View source code
Display the source code in std/experimental/allocator/building_blocks/kernighan_ritchie.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Function std.experimental.allocator.building_blocks.kernighan_ritchie.KRRegion.allocateAll

Allocates all memory available to this allocator. If the allocator is empty, returns the entire available block of memory. Otherwise, it still performs a best-effort allocation: if there is no fragmentation (e.g. allocate has been used but not deallocate), allocates and returns the only available block of memory.

void[] allocateAll();

The operation takes time proportional to the number of adjacent free blocks at the front of the free list. These blocks get coalesced, whether allocateAll succeeds or fails due to fragmentation.

Example

import std.experimental.allocator.gc_allocator : GCAllocator;
auto alloc = KRRegion!GCAllocator(1024 * 64);
const b1 = alloc.allocate(2048);
writeln(b1.length); // 2048
const b2 = alloc.allocateAll;
writeln(b2.length); // 1024 * 62

Authors

License