digitalmars.D.bugs - [Issue 16507] New: std.experimental.allocator: FreeTree clears too
- via Digitalmars-d-bugs (42/42) Sep 18 2016 https://issues.dlang.org/show_bug.cgi?id=16507
https://issues.dlang.org/show_bug.cgi?id=16507 Issue ID: 16507 Summary: std.experimental.allocator: FreeTree clears too eagerly Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: ag0aep6g gmail.com Documentatinon [1] says: "If allocation from the parent succeeds, the allocated block is returned. Otherwise, [...] FreeTree releases all of its contents and tries again." ---- import std.experimental.allocator.building_blocks: FreeTree; struct MyAllocator { byte dummy; static bool alive = true; void[] allocate(size_t s) { return new byte[](s); } bool deallocate(void[] ) { if (alive) assert(false); return true; } enum alignment = size_t.sizeof; } void main() { FreeTree!MyAllocator ft; void[] x = ft.allocate(1); ft.deallocate(x); ft.allocate(1000); MyAllocator.alive = false; } ---- The assert is hit. It shouldn't be. For the second allocation, ft should allocate from the parent allocator without deallocating the free block. Pull request incoming. [1] --
Sep 18 2016