A Refcounted Array Type

via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 5 08:19:07 PST 2015


On Thursday, 5 March 2015 at 15:20:47 UTC, monarch_dodra wrote:
> On Monday, 23 February 2015 at 22:15:54 UTC, Walter Bright 
> wrote:
>>  private:
>>    E[] array;
>>    size_t start, end;
>>    int* count;
>
> What is the point of keeping start/end? Aren't those baked into 
> the array slice? Not storing start end means not having to do 
> index arithmetic (minor), reducing struct size (always nice). 
> But more importantly, it allows implicit (and conditional) 
> bounds checking (awesome), which actually runs regardless 
> anyways.
>
> Or did I miss something?

`GC.free()` needs a pointer to the start of the allocated block; 
it will not release memory if it gets an interior pointer. But as 
far as I can see, one pointer that stores the original address 
should be enough.


More information about the Digitalmars-d mailing list