Bug 18259 – allocatorObject's CAllocatorImpl should store the passed allocator within

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-01-17T22:03:38Z
Last change time
2018-01-17T22:55:56Z
Assigned to
Eduard Staniloiu
Creator
Eduard Staniloiu

Comments

Comment #0 by edi33416 — 2018-01-17T22:03:38Z
allocatorObject uses the passed allocator to allocate the memory chunk that will store the CAllocatorImpl instance, and thus, the allocator stored within the newly created instance should be the one that was passed to the function. This being said, the unittest below should pass. unittest { import std.conv; import std.experimental.allocator.mallocator; import std.experimental.allocator.building_blocks.stats_collector; alias SCAlloc = StatsCollector!(Mallocator, Options.bytesUsed); SCAlloc statsCollectorAlloc; assert(statsCollectorAlloc.bytesUsed == 0); auto _allocator = allocatorObject(statsCollectorAlloc); // Ensure that the allocator was passed through in CAllocatorImpl // This allocator was used to allocate the chunk that holds the // CAllocatorImpl object; which is it's own wrapper assert(_allocator.impl.bytesUsed == stateSize!(CAllocatorImpl!(SCAlloc))); _allocator.allocate(1); assert(_allocator.impl.bytesUsed == stateSize!(CAllocatorImpl!(SCAlloc)) + 1); }
Comment #1 by andrei — 2018-01-17T22:10:59Z
Comment #2 by github-bugzilla — 2018-01-17T22:55:55Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/7220c57286d1742104c058ccdb9ccec34f18a2dc Fix Issue 18259 - allocatorObject's CAllocatorImpl should store the passed allocator within https://github.com/dlang/phobos/commit/382a8ea922d53db5c27e2cd457b79348ed892078 Merge pull request #6044 from edi33416/fix_allocator_obj Fix Issue 18259 - allocatorObject's CAllocatorImpl should store the passed allocator within merged-on-behalf-of: Andrei Alexandrescu <[email protected]>