A Refcounted Array Type

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Feb 24 12:34:18 PST 2015


On 2/24/2015 6:56 AM, Steven Schveighoffer wrote:
> Actually, RCArray can never be allocated on GC, or you may corrupt memory. count
> may be non-null, and point at invalid memory when the dtor is called.

Just set count to null after the delete.

> Only safe way to do this is to C malloc/free the count. And yes, at that point,
> you need atomics.

No, RCArray is not intended for shared access between threads.

Shared containers and local containers are different enough that they merit 
being different types with different implementations altogether. Trying to just 
slap 'shared' on a container isn't going to work.



More information about the Digitalmars-d mailing list