On 7/16/16 12:45 PM, Luís Marques wrote:
On Saturday, 16 July 2016 at 16:19:11 UTC, Andrei Alexandrescu wrote:
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);
}

What's the solution? I would say the solution is to use theAllocator
instead, to allocate the CAllocatorImpl. Or maybe a template alias
parameter that defaults to theAllocator?

I don't know yet. Thinking of it. -- Andrei

Reply via email to