On 07/16/2016 12:07 PM, Andrei Alexandrescu wrote:
On 07/16/2016 10:23 AM, Luís Marques wrote:
On Friday, 15 July 2016 at 18:44:26 UTC, Luís Marques wrote:
I'm not having success trying to use the allocator API.
What am doing wrong here? (OS X, 64-bit)
[...]
Given the lack of feedback, I'm going to assume it's a bug.
https://issues.dlang.org/show_bug.cgi?id=16285
I reproduced this on Linux and looked around a bit. It's pretty vexing.
Thanks for submitting it. -- Andrei
Found the problem. Currently allocatorObject allocates the
CAllocatorImpl object (interface implementation) straight inside the
given allocator, in an ouroboros fashion. Subsequently, deallocateAll
deallocates he CAllocatorImpl itself.
CAllocatorImpl!(A, Yes.indirect) allocatorObject(A)(A* pa)
{
assert(pa);
import std.conv : emplace;
auto state = pa.allocate(stateSize!(CAllocatorImpl!(A, Yes.indirect)));
import std.traits : hasMember;
static if (hasMember!(A, "deallocate"))
{
scope(failure) pa.deallocate(state);
}
return emplace!(CAllocatorImpl!(A, Yes.indirect))
(state, pa);
}
Andrei