Bug 16008 – FreeList should implement deallocateAll, as SharedFreeList does

Status
REOPENED
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-05-10T05:36:41Z
Last change time
2024-12-01T16:26:46Z
Assigned to
No Owner
Creator
basile-z
Moved to GitHub: phobos#9682 →

Comments

Comment #0 by b2.temp — 2016-05-10T05:36:41Z
THis can be necessary. An example that was posted on SO ([1]), if one embeds a FreeList in an aggregate, it's very probable that the FreeList has to be cleared in the aggregate __ctor, which is not possible now. [1]: http://stackoverflow.com/questions/36719532/how-can-i-free-all-the-items-of-a-freelist
Comment #1 by n8sh.secondary — 2020-01-31T08:43:45Z
FreeList implements deallocateAll and appears to have already done so at the time this issue was created.
Comment #2 by b2.temp — 2020-01-31T11:09:12Z
It does not. If you look carefully it only appears that it is implemented because of the DbI style. So if you make a FreeList with Mallocator you cant deallocate all. here is a test case to prevent any further confusion --- void main() {} struct TestCase { import std.experimental.allocator.mallocator : Mallocator; import std.experimental.allocator.building_blocks : FreeList; FreeList!(Mallocator, 16, 16) freeList; ~this() { freeList.deallocateAll; } } ---
Comment #3 by atila.neves — 2022-07-18T16:26:36Z
FreeList implements deallocateAll iff the parent allocator implements it. There's no way for FreeList!Mallocator to do that since there's no way to deallocateAll for Mallocator. If you want to be able to call deallocateAll with a FreeList, use a different parent allocator that has that capability.
Comment #4 by robert.schadek — 2024-12-01T16:26:46Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9682 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB