On 2/19/16 9:21 PM, Steven Schveighoffer wrote:
I'm trying to use the std.experimental.allocator API more in my new io
library, and I'm having a few stumbling points:

Another thought:

Allocators return void[] when requesting allocations, reallocations, etc. For C malloc, the assumption must be that what you requested is what you got, because the actual block size isn't given. However, for GC (and I assume other allocators), we have mechanisms to know upon allocation the amount of data received.

I would assume since we are returning both pointer and length, it would be possible for an allocator to return more data than requested (why waste it?). But it appears that the GC allocator just returns the amount of data requested, even though it could return the extra data that was received.

Should the API assumptions allow returning more data than requested? It means code has to be wary of this, but creating a wrapper allocator that truncates the data would be trivial, no?

I want to write some PRs to fix this, but I'm unclear what is expected.

-Steve

Reply via email to