From 035d7d651b536977fe6e41d0c6968e47edcd5389 Mon Sep 17 00:00:00 2001 From: Eduard Staniloiu Date: Mon, 16 Oct 2017 08:56:28 +0000 Subject: [PATCH] Fix bucketizer aligned allocate --- std/experimental/allocator/building_blocks/bucketizer.d | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/std/experimental/allocator/building_blocks/bucketizer.d b/std/experimental/allocator/building_blocks/bucketizer.d index 64067ddc0..72dc5a54f 100644 --- a/std/experimental/allocator/building_blocks/bucketizer.d +++ b/std/experimental/allocator/building_blocks/bucketizer.d @@ -69,18 +69,19 @@ struct Bucketizer(Allocator, size_t min, size_t max, size_t step) } /** + Allocates the requested `bytes` of memory with specified `alignment`. Directs the call to either one of the $(D buckets) allocators. Defined only if `Allocator` defines `alignedAllocate`. */ static if (hasMember!(Allocator, "alignedAllocate")) - void[] alignedAllocate(size_t bytes, uint a) + void[] alignedAllocate(size_t bytes, uint alignment) { if (!bytes) return null; - if (auto a = allocatorFor(b.length)) + if (auto a = allocatorFor(bytes)) { const actual = goodAllocSize(bytes); - auto result = a.alignedAllocate(actual); - return result.ptr ? result.ptr[0 .. bytes] : null; + auto result = a.alignedAllocate(actual, alignment); + return result !is null ? (() @trusted => (&result)[0 .. bytes])() : null; } return null; }