From d8315267e83987df74133d6f2e2e4f3294fae7bb Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Mon, 5 May 2025 17:30:40 +0100 Subject: [PATCH] clear utf16 cache this stops the unicode global cache from showing in the memleak output --- Engine/source/core/strings/unicode.cpp | 5 +++++ Engine/source/core/strings/unicode.h | 4 +++- Engine/source/main/main.cpp | 3 ++- Engine/source/platformWin32/winWindow.cpp | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Engine/source/core/strings/unicode.cpp b/Engine/source/core/strings/unicode.cpp index ad43ad3e1..28fb25323 100644 --- a/Engine/source/core/strings/unicode.cpp +++ b/Engine/source/core/strings/unicode.cpp @@ -289,6 +289,11 @@ UTF8* createUTF8string( const UTF16* unistring) return ret; } +void UTF16ClearCache() +{ + sgUTF16Cache.clear(); +} + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- diff --git a/Engine/source/core/strings/unicode.h b/Engine/source/core/strings/unicode.h index ec26d1c91..009489630 100644 --- a/Engine/source/core/strings/unicode.h +++ b/Engine/source/core/strings/unicode.h @@ -66,6 +66,8 @@ UTF16* createUTF16string( const UTF8 *unistring); UTF8* createUTF8string( const UTF16 *unistring); +void UTF16ClearCache(); + //----------------------------------------------------------------------------- /// Functions that convert buffers of unicode code points, into a provided buffer. /// - These functions are useful for working on existing buffers. @@ -138,4 +140,4 @@ const UTF8* getNthCodepoint(const UTF8 *unistring, const U32 n); bool chompUTF8BOM( const char *inString, char **outStringPtr ); bool isValidUTF8BOM( U8 bom[4] ); -#endif // _UNICODE_H_ \ No newline at end of file +#endif // _UNICODE_H_ diff --git a/Engine/source/main/main.cpp b/Engine/source/main/main.cpp index 826f14d16..c0699b9a1 100644 --- a/Engine/source/main/main.cpp +++ b/Engine/source/main/main.cpp @@ -231,7 +231,7 @@ S32 TorqueMain(S32 argc, const char **argv) // argv = argvFake; // } -#if !defined(TORQUE_DISABLE_MEMORY_MANAGER) +#if defined( TORQUE_DEBUG ) && !defined(TORQUE_DISABLE_MEMORY_MANAGER) Memory::init(); #endif @@ -257,6 +257,7 @@ S32 TorqueMain(S32 argc, const char **argv) Platform::restartInstance(); + #if defined( TORQUE_DEBUG ) && !defined( TORQUE_DISABLE_MEMORY_MANAGER ) Memory::shutdown(); #endif diff --git a/Engine/source/platformWin32/winWindow.cpp b/Engine/source/platformWin32/winWindow.cpp index 011884ce4..4661140d1 100644 --- a/Engine/source/platformWin32/winWindow.cpp +++ b/Engine/source/platformWin32/winWindow.cpp @@ -317,6 +317,8 @@ void Platform::shutdown() GFXDevice::destroy(); WinConsole::destroy(); + + UTF16ClearCache(); } extern bool LinkConsoleFunctions;