std.allocator ready for some abuse

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Oct 27 14:58:56 PDT 2013


On 10/25/13 7:23 AM, Manu wrote:
> 1. I'm still sad there are no allocAligned() functions or something of
> that type to request explicit alignment with allocations. I'm not sure
> there is sufficient support for requesting alignment with allocations.
> The set-able alignment property approach seems a little weird (and only
> seemed to be supported on one allocator?). I guess experience will tell
> if this is sufficient and/or convenient.
> I'd still like to see an allocWithAlignment() method or something, which
> may be implemented efficiently by allocators that can support it.

Code: http://erdani.com/d/phobos-prerelease/std_allocator.html

Dox: http://erdani.com/d/phobos-prerelease/std_allocator.html

I've made alignedAllocate() and alignedReallocate() parts of the 
official API, added alignedAlloc to all regions, added AlignedMallocator 
which taps into the aligned system APIs, and eliminated all that dynamic 
alignment setting stuff. I think we're in better shape now. Thanks for 
the suggestion!

I still need to:

1. add stats for aligned calls to AllocatorWithStats

2. define HeapBlock.alignedXxx (which should be interesting)

3. separate IOwns, IAlignedAllocate, IDeallocate from CAllocator and 
have CAllocatorImpl!alloc conditionally implement them depending on 
whether alloc implements the respective primitives.


Andrei



More information about the Digitalmars-d mailing list