New adapter: std.allocator.quantizer

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri May 15 09:58:04 PDT 2015


On 5/12/15 12:57 PM, Timon Gehr wrote:
> On 05/12/2015 04:54 AM, Andrei Alexandrescu wrote:
>> On 5/11/15 4:59 PM, Timon Gehr wrote:
>>> On 05/11/2015 08:48 PM, Andrei Alexandrescu wrote:
>>>> On 5/11/15 11:31 AM, Timon Gehr wrote:
>>>>> - The assertion in line 141 may fail. (expand can return false.)
>>>>
>>>> OK, it seems the previous commit should take care of that.
>>>> ...
>>>
>>> Nope.
>>>
>>> Well, yes, in the sense that there is no longer a possibly failing
>>> assertion on line 141.
>>>
>>> In any case, 'allocate' within 'expand' may fail, and if it does, b.ptr
>>> will still be null throughout the body of reallocate/alignedReallocate.
>>
>> Somebody shoot me :o).
>>
>> https://github.com/andralex/phobos/commit/18d5cd9526db5057cacff5832a6246d1f84ada2a
>>
>> ...
>
> Missed alignedReallocate. :o)
>
> On a related note, alignedReallocate is now also buggy in that it does
> not necessarily align the allocated memory if b.ptr is null.

Missed this, thanks for the email! I've simplified matters a bit by 
testing for null up front:

https://github.com/andralex/phobos/commit/af0abf6adb325cf57f2ef0f07bf787ebb1351288

I suspect the other allocators have similar issues though... I'll need 
to make a careful pass.


Thanks!!

Andrei




More information about the Digitalmars-d mailing list