std.allocator issues
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Fri Feb 19 18:21:00 PST 2016
I'm trying to use the std.experimental.allocator API more in my new io
library, and I'm having a few stumbling points:
1. GCAllocator only allocates void, which is marked as containing
pointers. This is no good for a stream buffer, and can severely harm
performance.
2. GCAllocator provides a free function. There's no way for me to tell
generically that it's OK *not* to free allocations, though. I understand
we should provide a hook if there exists a way to do so, but there needs
to be a way to free this. I'd prefer not to free data if it's not
strictly necessary.
3. GCAllocator needs a mechanism to specify type info for allocations so
the dtors are properly run in the GC. While not critical for my
purposes, this is going to be very important, and should be figured out
before merged into mainline Phobos.
4. Various functions in std.allocator take a ref void[]. This is no
good. I don't want to store a void[] in my type, because that's not very
useful, but if I want to reallocate, or expand, then I need to do a
dance where I copy the array to a void[], do the reallocation, and then
copy it back (if successful). This fully defeats the point of having a
ref in the first place. I understand there are wrappers that do this for
reallocating, but I want to use the other tools as well (expand in
particular). But principally, to have an API that is mostly unusable
seems unnecessary.
I really do like the API, and it's fitting in quite nicely! I can work
around all these at the moment, but I'd love to see these improvements
in place before making official phobos.
-Steve
More information about the Digitalmars-d
mailing list