forked from boostorg/unordered
made clear reset overflow bytes
This commit is contained in:
@ -1364,11 +1364,24 @@ public:
|
|||||||
|
|
||||||
void clear()noexcept
|
void clear()noexcept
|
||||||
{
|
{
|
||||||
for_all_elements([&,this](group_type* pg,unsigned int n,value_type* p){
|
alignas(group_type) static constexpr unsigned char
|
||||||
destroy_element(p);
|
zero[sizeof(group_type)]={0,};
|
||||||
pg->reset(n);
|
|
||||||
});
|
auto p=arrays.elements;
|
||||||
size_=0;
|
if(p){
|
||||||
|
for(auto pg=arrays.groups,last=pg+arrays.groups_size_mask+1;
|
||||||
|
pg!=last;++pg,p+=N){
|
||||||
|
auto mask=pg->match_really_occupied();
|
||||||
|
while(mask){
|
||||||
|
destroy_element(p+unchecked_countr_zero(mask));
|
||||||
|
mask&=mask-1;
|
||||||
|
}
|
||||||
|
/* we wipe the entire metadata to reset the overflow byte as well */
|
||||||
|
*pg=*reinterpret_cast<const group_type*>(zero);
|
||||||
|
}
|
||||||
|
arrays.groups[arrays.groups_size_mask].set_sentinel();
|
||||||
|
size_=0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: should we accept different allocator too?
|
// TODO: should we accept different allocator too?
|
||||||
|
Reference in New Issue
Block a user