TempAlloc: an unusual request

dsimcha dsimcha at yahoo.com
Sun Jun 19 19:48:37 PDT 2011


On 6/19/2011 8:00 PM, Andrei Alexandrescu wrote:
> On 06/19/2011 06:20 PM, dsimcha wrote:
>> It's ok to allow an object to replace frameInit and frameFree for
>> conformance to the general allocator interface, but I'd need to keep
>> frameInit and frameFree around. They're useful for functions that return
>> pointers to TempAlloc-allocated memory. I don't want to have to pass in
>> a RegionAllocator object to each of these because it's too verbose. I
>> want to be able to do:
>>
>> void doStuff() {
>> TempAlloc.frameInit();
>> scope(exit) TempAlloc.frameFree();
>>
>> auto arr = getArray();
>> }
>>
>> uint[] getArray() {
>> return TempAlloc.newArray!(uint[])(5);
>> }
>>
>>
>> My other concern is that giving RegionAllocator reference semantics
>> would, IIUC, require an allocation to allocate a RegionAllocator. Since
>> TempAlloc is designed to avoid global GC locks/world stopping like the
>> plauge, this is obviously bad.
>
> I was actually glad of that particular outcome...

??? What outcome?


More information about the Digitalmars-d mailing list