no more leaks in vector

This commit is contained in:
hugogogo
2022-06-17 01:36:45 +02:00
parent df6332b496
commit 64d87cb5d4

View File

@@ -52,7 +52,12 @@ VT_TPL VT::
}
// destructors -------------------------------
VT_TPL VT::
~vector() { return; }
~vector() {
clear();
_allocator.deallocate(_mem_ptr, _capacity);
return;
}
// operator= ---------------------------------
VT_TPL VT & VT::
operator=( vector const & rhs ) {
@@ -152,15 +157,14 @@ VT_TPL void VT::
_capacity = new_cap;
tmp_ptr = _allocator.allocate(new_cap);
_mem_ptr = tmp_ptr;
if (_mem_ptr)
{
_mem_ptr = tmp_ptr;
_size = 0;
assign(first, last);
_destroy(begin(), end());
_allocator.deallocate(old_ptr, _capacity);
}
_mem_ptr = tmp_ptr;
}