Fix hashtable node deallocation
François Dumont
frs.dumont@gmail.com
Sun Dec 16 13:17:00 GMT 2018
Gentle reminder, we still have this issue pending.
   * include/bits/hashtable_policy.h
(_Hashtable_alloc<>::_M_deallocate_node_ptr(__node_type*)): New.
   (_Hashtable_alloc<>::_M_deallocate_node(__node_type*)): Use latter.
(_ReuseOrAllocNode<>::operator<_Arg>()(_Arg&&)): Likewise.
   * libstdc++-v3/testsuite/util/testsuite_allocator.h
   (CustomPointerAlloc<>::allocate(size_t, pointer)): Replace by...
   (CustomPointerAlloc<>::allocate(size_t, const_void_pointer)): ...this.
François
On 11/29/18 7:08 AM, François Dumont wrote:
> I am unclear about this patch, is it accepted ?
>
>
> On 11/19/18 10:19 PM, François Dumont wrote:
>> On 11/19/18 1:34 PM, Jonathan Wakely wrote:
>>> On 10/11/18 22:40 +0100, François Dumont wrote:
>>>> While working on a hashtable enhancement I noticed that we are not
>>>> using the correct method to deallocate node if the constructor
>>>> throws in _ReuseOrAllocNode operator(). I had to introduce a new
>>>> _M_deallocate_node_ptr for that as node value shall not be destroy
>>>> again.
>>>>
>>>> I also check other places and noticed that a __node_type destructor
>>>> call was missing.
>>>
>>> That's intentional. The type has a trivial destructor, so its storage
>>> can just be reused, we don't need to destroy it.
>>>
>>>
>> Ok, do you want to also remove the other call to ~__node_type() then ?
>>
>> Here is the updated patch and the right ChangeLog entry:
>>
>> Â Â Â * include/bits/hashtable_policy.h
>> (_Hashtable_alloc<>::_M_deallocate_node_ptr(__node_type*)): New.
>> (_Hashtable_alloc<>::_M_deallocate_node(__node_type*)): Use latter.
>> (_ReuseOrAllocNode<>::operator<_Arg>()(_Arg&&)): Likewise.
>> Â Â Â (_Hashtable_alloc<>::_M_allocate_node): Add ~__node_type call.
>> Â Â Â * libstdc++-v3/testsuite/util/testsuite_allocator.h
>> Â Â Â (CustomPointerAlloc<>::allocate(size_t, pointer)): Replace by...
>> Â Â Â (CustomPointerAlloc<>::allocate(size_t, const_void_pointer)):
>> ...this.
>> Â Â Â * testsuite/23_containers/unordered_set/allocator/ext_ptr.cc: Add
>> Â Â Â check.
>>
>> Ok to commit ?
>>
>> François
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hashtable_dealloc.patch
Type: text/x-patch
Size: 2128 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20181216/dea8868d/attachment.bin>
More information about the Libstdc++
mailing list