On 5/14/14, 6:11 PM, Brian Schott wrote:
On Thursday, 15 May 2014 at 00:48:52 UTC, Walter Bright wrote:
On 5/14/2014 5:44 PM, Brian Schott wrote:
Can we say that Mallocator failures are not recoverable?
malloc itself does not have that property. But you could design a
wrapper for it that did.
I'm concerned specifically with this wrapper:
https://github.com/andralex/phobos/blob/allocator/std/allocator.d#L773
We need to make these functions pure if they are going to be usable.
Removing the stdlib import and adding
private extern (C)
{
void* malloc(size_t) pure nothrow @trusted;
void free(void*) pure nothrow @trusted;
void* realloc(void*, size_t) pure nothrow @trusted;
}
as well as a throwing OutOfMemoryError if they fail should be
sufficient, correct?
I think so. A more cautious solution would be to define PureMallocator
in addition to Mallocator.
Andrei