Browse Source

Update console.h

might not fix the leak we were having around callbacks, but it really slows down the upcreep of memory
marauder2k7 5 months ago
parent
commit
ea39c83afd
1 changed files with 5 additions and 5 deletions
  1. 5 5
      Engine/source/console/console.h

+ 5 - 5
Engine/source/console/console.h

@@ -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);