[Issue 23318] GCAllocator should not implement deallocate
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Sep 23 11:29:07 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23318
Dlang Bot <dlang-bot at dlang.rocks> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |pull
--- Comment #4 from Dlang Bot <dlang-bot at dlang.rocks> ---
@pbackus updated dlang/phobos pull request #8554 "Remove deallocate and
reallocate from GCAllocator" fixing this issue:
- Remove GCAllocator.deallocate
This is necessary to make clients of GCAllocator (e.g., generic
containers) usable in @safe code.
Memory allocated by GC allocator will still be freed by the GC when it
is no longer reachable.
Rejected alternatives:
- Making GCAllocator.deallocate a no-op method that always returns
false. The documentation in std.experimental.allocator.building_blocks
specifically says not to do that.
- Special-casing client code for GCAllocator to avoid calling its
'deallocate' method, while still calling 'deallocate' for other
allocators.
'deallocate' has been documented as an optional method since
std.experimental.allocator was introduced in 2015 (commit 8b249a6240),
so this change will not break code that correctly adheres to the
documented allocator interface (i.e., checks for the presence of
'deallocate' before calling it).
Fixes issue 23318.
https://github.com/dlang/phobos/pull/8554
--
More information about the Digitalmars-d-bugs
mailing list