From c02e738866729686bfe97aad032043d2c68d36ae Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 1 May 2023 22:49:53 +0200 Subject: [PATCH] Fix utlvector and utlstring destructor bug Fix duplicate call to CUtlMemory::Purge. This was caused due to an extra call performed in the destructor of CUtlVector and CUtlString. Disassembling the DLL after performing these changes revealed the destructor of the allocator is only getting called once now; the issue has been fixed. --- r5dev/public/tier1/utlstring.h | 9 --------- r5dev/public/tier1/utlvector.h | 3 ++- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/r5dev/public/tier1/utlstring.h b/r5dev/public/tier1/utlstring.h index 2460adc2..bbffb398 100644 --- a/r5dev/public/tier1/utlstring.h +++ b/r5dev/public/tier1/utlstring.h @@ -32,15 +32,6 @@ public: #else m_nActualLength = 0; #endif - - // Has to be explicitly called due to the - // current design of our SDK. Unlike other - // Source Engine games, we couldn't import - // the memalloc singleton as the executable - // is monolithic; we obtain it post init - // (too late for binding it against the - // new/delete operators..). - m_Memory.~CUtlMemory(); } // NOTE: nInitialLength indicates how much of the buffer starts full diff --git a/r5dev/public/tier1/utlvector.h b/r5dev/public/tier1/utlvector.h index c8773746..f82f2361 100644 --- a/r5dev/public/tier1/utlvector.h +++ b/r5dev/public/tier1/utlvector.h @@ -648,7 +648,8 @@ inline CUtlVector::CUtlVector(T* pMemory, int allocationCount, int numElem template< typename T, class A > inline CUtlVector::~CUtlVector() { - Purge(); + RemoveAll(); + // Destructor of allocator calls purge. } template< typename T, class A >