std.allocator ready for some abuse
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Oct 24 14:20:46 PDT 2013
On 10/24/13 2:16 PM, Artem Tarasov wrote:
> The design looks great. Easy to grasp and covers almost all imaginable
> use cases.
>
> 'Almost' because it would be nice to also have ScopeAllocator!N ~
> FallbackAllocator!(InsituRegion!N, Mallocator) which would automatically
> deallocate all heap-allocated blocks when exiting the scope (i.e. no
> deallocate method, array of pointers to be freed is kept on a C heap).
Great point, clearly you cut to the chase :o). Yes, I hope to integrate
that, and I'm a bit pained I didn't have the time to do that.
The way I see that could be done is by defining a ScopedAllocator that
uses internally an AffixAllocator with a doubly-linked list tracking all
allocations. In the destructor, ScopedAllocator would walk the list and
deallocate everything allocated since its construction.
Andrei
More information about the Digitalmars-d
mailing list