RCArray is unsafe

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 3 10:44:20 PST 2015


On 3/3/2015 9:44 AM, Andrei Alexandrescu wrote:
> On 3/3/15 9:40 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm at gmx.net>" wrote:
>> All instances need to carry a pointer to refcount anyway, so the
>> freelist could just be stored next to the refcount. The idea of creating
>> that list, however, is more worrying, because it again involves
>> allocations. It can get arbitrarily long.
> No, the cool thing about freelists is they use free memory to chain things
> together.

I don't think the payload memory can be repurposed to be a free list until the 
destructor runs, because the whole problem is the payload may still be live to 
some references to it.


More information about the Digitalmars-d mailing list