From ee0cf872a0204e235fdb1494aeccddee8213d77b Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Thu, 8 May 2025 20:40:17 +0100 Subject: [PATCH] moar leak plug attempts --- Engine/source/console/console.h | 101 +++++++++++++++++- Engine/source/console/consoleInternal.cpp | 4 +- Engine/source/console/consoleInternal.h | 2 +- Engine/source/console/consoleObject.cpp | 6 ++ Engine/source/console/simEvents.cpp | 2 +- .../source/console/torquescript/evalState.h | 4 +- 6 files changed, 108 insertions(+), 11 deletions(-) diff --git a/Engine/source/console/console.h b/Engine/source/console/console.h index ef83ed397..1b5b47fb0 100644 --- a/Engine/source/console/console.h +++ b/Engine/source/console/console.h @@ -203,17 +203,108 @@ public: ConsoleValue(ConsoleValue&& ref) noexcept { - _move(std::move(ref)); + type = ref.type; + + switch (ref.type) + { + case cvInteger: + i = ref.i; + break; + case cvFloat: + f = ref.f; + break; + case cvSTEntry: + TORQUE_CASE_FALLTHROUGH; + case cvString: + s = ref.s; + ref.s = const_cast(StringTable->EmptyString()); + break; + default: + data = ref.data; + + break; + } + ref.type = ConsoleValueType::cvSTEntry; + ref.data = NULL; } TORQUE_FORCEINLINE ConsoleValue& operator=(ConsoleValue&& ref) noexcept { - _move(std::move(ref)); + type = ref.type; + + switch (ref.type) + { + case cvInteger: + i = ref.i; + break; + case cvFloat: + f = ref.f; + break; + case cvSTEntry: + TORQUE_CASE_FALLTHROUGH; + case cvString: + s = ref.s; + ref.s = const_cast(StringTable->EmptyString()); + break; + default: + data = ref.data; + + break; + } + ref.type = ConsoleValueType::cvSTEntry; + ref.data = NULL; return *this; } - ConsoleValue(const ConsoleValue&) = delete; - ConsoleValue& operator=(const ConsoleValue&) = delete; + ConsoleValue(const ConsoleValue& ref) + { + type = ref.type; + + switch (ref.type) + { + case cvInteger: + i = ref.i; + break; + case cvFloat: + f = ref.f; + break; + case cvSTEntry: + TORQUE_CASE_FALLTHROUGH; + case cvString: + s = ref.s; + break; + default: + data = ref.data; + + break; + } + } + + ConsoleValue& operator=(const ConsoleValue& ref) + { + type = ref.type; + + switch (ref.type) + { + case cvInteger: + i = ref.i; + break; + case cvFloat: + f = ref.f; + break; + case cvSTEntry: + TORQUE_CASE_FALLTHROUGH; + case cvString: + s = ref.s; + break; + default: + data = ref.data; + + break; + } + + return *this; + } TORQUE_FORCEINLINE ~ConsoleValue() { @@ -1022,7 +1113,7 @@ namespace Con ConsoleValue executef(R r, ArgTs ...argTs) { _EngineConsoleExecCallbackHelper callback(r); - return std::move(callback.template call(argTs...)); + return (callback.template call(argTs...)); } /// } }; diff --git a/Engine/source/console/consoleInternal.cpp b/Engine/source/console/consoleInternal.cpp index f0f17b604..454af91ec 100644 --- a/Engine/source/console/consoleInternal.cpp +++ b/Engine/source/console/consoleInternal.cpp @@ -1159,7 +1159,7 @@ ConsoleValue Namespace::Entry::execute(S32 argc, ConsoleValue *argv, SimObject * { if (mFunctionOffset) { - return std::move(mModule->exec(mFunctionOffset, argv[0].getString(), mNamespace, argc, argv, false, mPackage).value); + return (mModule->exec(mFunctionOffset, argv[0].getString(), mNamespace, argc, argv, false, mPackage).value); } else { @@ -1173,7 +1173,7 @@ ConsoleValue Namespace::Entry::execute(S32 argc, ConsoleValue *argv, SimObject * if (mToolOnly && !Con::isCurrentScriptToolScript()) { Con::errorf(ConsoleLogEntry::Script, "%s::%s - attempting to call tools only function from outside of tools", mNamespace->mName, mFunctionName); - return std::move(ConsoleValue()); + return (ConsoleValue()); } #endif diff --git a/Engine/source/console/consoleInternal.h b/Engine/source/console/consoleInternal.h index 6c0c91828..9a32dbe7c 100644 --- a/Engine/source/console/consoleInternal.h +++ b/Engine/source/console/consoleInternal.h @@ -321,7 +321,7 @@ public: void reset(); - inline ConsoleValue getValue() { return std::move(value); } + inline ConsoleValue getValue() { return (value); } inline U32 getIntValue() { diff --git a/Engine/source/console/consoleObject.cpp b/Engine/source/console/consoleObject.cpp index 9156c1da7..eed85cbfa 100644 --- a/Engine/source/console/consoleObject.cpp +++ b/Engine/source/console/consoleObject.cpp @@ -286,6 +286,12 @@ void AbstractClassRep::shutdown() // Release storage allocated to the class table. + for (auto walk = classLinkList; walk; walk = walk->nextClass) + { + walk->mFieldList.clear(); + walk->mFieldList.compact(); // Important: frees the internal buffer + } + for (U32 group = 0; group < NetClassGroupsCount; group++) for(U32 type = 0; type < NetClassTypesCount; type++) if( classTable[ group ][ type ] ) diff --git a/Engine/source/console/simEvents.cpp b/Engine/source/console/simEvents.cpp index b02e6fa0d..47924082e 100644 --- a/Engine/source/console/simEvents.cpp +++ b/Engine/source/console/simEvents.cpp @@ -116,7 +116,7 @@ ConsoleValue SimConsoleThreadExecCallback::waitForResult() { if(sem->acquire(true)) { - return std::move(retVal); + return (retVal); } return ConsoleValue(); diff --git a/Engine/source/console/torquescript/evalState.h b/Engine/source/console/torquescript/evalState.h index cd0d34a13..599af113e 100644 --- a/Engine/source/console/torquescript/evalState.h +++ b/Engine/source/console/torquescript/evalState.h @@ -1,4 +1,4 @@ -#ifndef _EVALSTATE_H +#ifndef _EVALSTATE_H #define _EVALSTATE_H #include "console/consoleInternal.h" @@ -81,7 +81,7 @@ public: currentRegisterArray->values[reg].setStringTableEntry(val); } - TORQUE_FORCEINLINE void moveConsoleValue(S32 reg, ConsoleValue val) + TORQUE_FORCEINLINE void moveConsoleValue(S32 reg, ConsoleValue&& val) { currentRegisterArray->values[reg] = std::move(val); }