New adapter: std.allocator.quantizer

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Mon May 11 16:38:04 PDT 2015


On 05/11/2015 08:45 PM, Andrei Alexandrescu wrote:
> On 5/11/15 11:06 AM, Timon Gehr wrote:
>> - If the rounding function is not piecewise constant with one fixed
>> point per piece, it can happen that 'allocated >= needed' but 'allocated
>> < goodAllocSize(needed)'. Then, the allocated size will be inconsistent
>> with goodAllocSize. (This is why I recommended to require the rounding
>> function to have this property, which is stronger than monotonicity.)
>
> Got it. That's a rather subtle requirement, so I changed the code to
> keep things simple for the user:
>
> https://github.com/andralex/phobos/commit/9307b9f8969b7bfd0906e0441a13cbbded7f8418
> ...

OK. It can make things unnecessarily slow though. (Is there any 
compelling use case for a Quantizer that always leaves some unused slack 
space, no matter the allocation size?)

>
>> - If b.ptr is null, then line 113 is bad in case goodAllocSize(0) > 0.
>
> That should be fixed in the same commit; I just handle expansion of null
> blocks up front in expand().
> ...

OK.



More information about the Digitalmars-d mailing list