std.allocator.allocate(0) -> return null or std.allocator.allocate(1)?
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Sat May 16 23:07:54 PDT 2015
On 5/16/15 1:22 PM, Walter Bright wrote:
> On 5/16/2015 9:34 AM, Andrei Alexandrescu wrote:
>> Once the memory in the front buffer is exhausted, the fallback
>> allocator starts
>> getting used. The correct way to handle the choice in the composer is
>> to first
>> try the front, and if it returns null, defer to the fallback.
>>
>> Many other allocators follow similar patterns.
>
> Ah, ok, that makes sense. I was thinking more in terms of the whole
> program running out of memory, not fallback.
One more illustration of the same idea: just completed a larger doc.
http://erdani.com/d/phobos-prerelease/std_experimental_allocator_kernighan_ritchie.html
The Kernighan-Ritchie allocator is composed of a list of blocks, each
organized as a free list; when one block gets exhausted, the list
detects that and allocates more.
Andrei
More information about the Digitalmars-d
mailing list