Bulk allocation and partial deallocation for tree data structures.

Moritz Maxeiner via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 3 21:11:11 PDT 2017


On Tuesday, 4 July 2017 at 03:13:14 UTC, Filip Bystricky wrote:
> Oh and I forgot to mention: another use-case for this would be 
> for arrays. For manually managed arrays like 
> std.container.array, it would make it possible to transfer 
> ownership of individual objects from the array back to the 
> program after the array goes out of scope.

Not sure I understand you here: If an instance of such a manual 
array implementation goes out of scope it must destruct (if they 
are objects and not primitives) and deallocate its elements. 
There is no ownership transfer going on here (and who would be 
the target, anyway?).

> For gc slices, it could enable some gc implementations to 
> deallocate parts of an array even if there are still references 
> pointing inside that array.

I'm fairly certain the necessary bookkeeping logic for partial 
deallocations will outweigh any gain from it. In the case of such 
gc slices, I would rather just memcpy to a new, smaller block and 
update pointers to it (-> a moving GC).


More information about the Digitalmars-d-learn mailing list