std.allocator needs your help

Robert jfanatiker at gmx.at
Tue Sep 24 02:49:05 PDT 2013


On Mon, 2013-09-23 at 10:53 -0700, Andrei Alexandrescu wrote:
> void deallocate(void[] buffer);
> 
> This is because the size of D objects is naturally known: classes
> have 
> it in the classinfo, slices store it, and the few cases of using bald 
> pointers for allocation are irrelevant and unrecommended.


One concern though: void[] is just a slice, who guarantees that the size
matches the one that was allocated?

Is the allocator assumed to handle this correctly:

   auto arr = allocate(100);
   auto arr2 = arr[50..100];
   arr = arr[0..50];
   deallocate(arr);
   deallocate(arr2);

?

Or is the user simply obliged to use the originally returned range?

Best regards,

Robert



More information about the Digitalmars-d mailing list