import std.experimental.allocator.building_blocks.free_list : FreeList; import std.experimental.allocator.gc_allocator : GCAllocator; import std.experimental.allocator.mallocator : Mallocator; alias A = Segregator!( 128, FreeList!(Mallocator, 0, 128), 1024 * 4, GCAllocator, 1024 * 1024, Mallocator, GCAllocator ); A a; auto b = a.allocate(201); assert(b.length == 201); a.deallocate(b);
A Segregator with more than three arguments expands to a composition of elemental Segregators, as illustrated by the following example:
With this definition, allocation requests for n1 bytes or less are directed to A1; requests between n1 + 1 and n2 bytes (inclusive) are directed to A2; requests between n2 + 1 and n3 bytes (inclusive) are directed to A3; and requests for more than n3 bytes are directed to A4. If some particular range should not be handled, NullAllocator may be used appropriately.