Update console.h

might not fix the leak we were having around callbacks, but it really slows down the upcreep of memory
This commit is contained in:
marauder2k7 2025-05-08 13:35:55 +01:00
parent bab75a3a46
commit ea39c83afd

View file

@ -152,7 +152,7 @@ class ConsoleValue
TORQUE_FORCEINLINE bool hasAllocatedData() const TORQUE_FORCEINLINE bool hasAllocatedData() const
{ {
return (type == ConsoleValueType::cvString || isConsoleType()) && data != NULL; return (type == ConsoleValueType::cvString || isConsoleType()) && data != NULL;
} }
const char* getConsoleData() const; const char* getConsoleData() const;
@ -182,14 +182,16 @@ class ConsoleValue
TORQUE_CASE_FALLTHROUGH; TORQUE_CASE_FALLTHROUGH;
case cvString: case cvString:
s = ref.s; s = ref.s;
ref.s = const_cast<char*>(StringTable->EmptyString());
break; break;
default: default:
data = ref.data; data = ref.data;
break; break;
} }
ref.type = ConsoleValueType::cvSTEntry;
ref.data = NULL; ref.data = NULL;
ref.setEmptyString(); //ref.reset();
} }
public: public:
@ -305,9 +307,7 @@ public:
} }
cleanupData(); cleanupData();
type = ConsoleValueType::cvString; type = ConsoleValueType::cvString;
s = (char*)dMalloc(static_cast<dsize_t>(len) + 1); s = (char*)dMalloc(static_cast<dsize_t>(len) + 1);
s[len] = '\0'; s[len] = '\0';
dStrcpy(s, val, static_cast<dsize_t>(len) + 1); dStrcpy(s, val, static_cast<dsize_t>(len) + 1);