implemented delete correction for leaks
This commit is contained in:
@@ -138,6 +138,9 @@ VT_TPL void VT::
|
||||
reserve( size_type new_cap ) {
|
||||
|
||||
value_type * tmp_ptr;
|
||||
value_type * old_ptr = _mem_ptr;
|
||||
iterator first = begin();
|
||||
iterator last = end();
|
||||
|
||||
if (new_cap > _allocator.max_size())
|
||||
throw std::length_error("reserve: new_cap > max_size");
|
||||
@@ -151,10 +154,11 @@ VT_TPL void VT::
|
||||
|
||||
if (_mem_ptr)
|
||||
{
|
||||
for (size_type i = 0; i < _size; i++)
|
||||
tmp_ptr[i] = _mem_ptr[i];
|
||||
_mem_ptr = tmp_ptr;
|
||||
_size = 0;
|
||||
assign(first, last);
|
||||
_destroy(begin(), end());
|
||||
_allocator.deallocate(_mem_ptr, _capacity);
|
||||
_allocator.deallocate(old_ptr, _capacity);
|
||||
}
|
||||
_mem_ptr = tmp_ptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user