Allocator-aware @safe reference counting is still not possible
Paul Backus
snarwin at gmail.com
Mon Jan 30 16:27:30 UTC 2023
On Monday, 30 January 2023 at 12:30:01 UTC, Richard (Rikki)
Andrew Cattermole wrote:
> On 31/01/2023 1:17 AM, Dukc wrote:
>>
>> This could be accomplished with building a wrapper type over
>> `malloc`ed pointers. `@safe` `free` would accept only them,
>> not any isolated pointer.
>
> This is just horrible. You might as well call it DynamicArray
> which is exactly what I recommend you do, use data structures
> and not call allocators directly!
I don't understand why you keep bringing this up--it's totally
beside the point. Obviously most users should not need to use the
allocator API directly.
However, if you are *implementing* a data structure like a
dynamic array, and you want to support user-supplied custom
allocators, then the only way your data structure can be @safe is
if the allocator API uses this kind of wrapper type to present a
@safe interface.
More information about the Digitalmars-d
mailing list