Merge pull request #5781 from edi33416/bucketizer_fix

Fix bucketizer aligned allocate
merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
This commit is contained in:
The Dlang Bot 2017-10-16 14:14:22 +02:00 committed by GitHub
commit 58a987ae5f

View file

@ -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;
}