phobos/changelog/std-experimental-allocator-rcisharedallocator.dd
2018-01-25 14:19:21 +01:00

23 lines
855 B
Text

Replace `std.experimental.allocator.ISharedAllocator` with `std.experimental.allocator.RCISharedAllocator`
$(B Motivation):
Keep track of references to allocators so they don't escape, dangle,
and cause undefined behavior.
From now on, `RCISharedAllocator` will be used instead of the old
`ISharedAllocator` interface.
$(REF sharedAllocatorObject, std, experimental, allocator)` can be used to build
a `RCISharedAllocator` out of a custom allocator.
------
import std.experimental.allocator.building_blocks.free_list : SharedFreeList;
import std.experimental.allocator.mallocator : Mallocator;
shared SharedFreeList!(Mallocator, chooseAtRuntime, chooseAtRuntime) sharedFL;
shared RCISharedAllocator sharedFLObj = sharedAllocatorObject(sharedFL);
auto b = sharedFLObj.allocate(100);
assert(b.length == 100);
assert(sharedFLObj.deallocate(b));
------