1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Free Vector's memory during move assignment.

This commit is contained in:
Bartosz Taudul 2019-11-08 22:52:23 +01:00
parent a1488a74a1
commit 31e2bc1141

View File

@ -63,7 +63,11 @@ public:
Vector& operator=( const Vector& ) = delete; Vector& operator=( const Vector& ) = delete;
tracy_force_inline Vector& operator=( Vector&& src ) noexcept tracy_force_inline Vector& operator=( Vector&& src ) noexcept
{ {
delete[] (T*)m_ptr; if( m_capacity != MaxCapacity() )
{
memUsage.fetch_sub( Capacity() * sizeof( T ), std::memory_order_relaxed );
delete[] (T*)m_ptr;
}
memcpy( this, &src, sizeof( Vector<T> ) ); memcpy( this, &src, sizeof( Vector<T> ) );
memset( &src, 0, sizeof( Vector<T> ) ); memset( &src, 0, sizeof( Vector<T> ) );
return *this; return *this;