From ff6c0f1dfc2405b4d0f92d08079d390fc4cc14a0 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Wed, 12 Jul 2017 21:22:52 +0200 Subject: [PATCH] Issue 16984 - Make stdx.allocator.building_blocks.quantizer runnable --- std/experimental/allocator/building_blocks/quantizer.d | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/std/experimental/allocator/building_blocks/quantizer.d b/std/experimental/allocator/building_blocks/quantizer.d index b3f205dcc61..6df77e59468 100644 --- a/std/experimental/allocator/building_blocks/quantizer.d +++ b/std/experimental/allocator/building_blocks/quantizer.d @@ -212,14 +212,19 @@ struct Quantizer(ParentAllocator, alias roundingFunction) @system unittest { import std.experimental.allocator.building_blocks.free_tree : FreeTree; - import std.experimental.allocator.common : roundUpToMultipleOf; import std.experimental.allocator.gc_allocator : GCAllocator; + size_t roundUpToMultipleOf(size_t s, uint base) + { + auto rem = s % base; + return rem ? s + base - rem : s; + } + // Quantize small allocations to a multiple of cache line, large ones to a // multiple of page size alias MyAlloc = Quantizer!( FreeTree!GCAllocator, - n => n.roundUpToMultipleOf(n <= 16_384 ? 64 : 4096)); + n => roundUpToMultipleOf(n, n <= 16_384 ? 64 : 4096)); MyAlloc alloc; const buf = alloc.allocate(256); assert(buf.ptr);