Przeglądaj źródła

[cocos2dx] Closes #2505, fix warning about memory allocated by Cococs2d-X

Mario Zechner 1 rok temu
rodzic
commit
9c9bcb9428
1 zmienionych plików z 9 dodań i 1 usunięć
  1. 9 1
      spine-cpp/spine-cpp/include/spine/Debug.h

+ 9 - 1
spine-cpp/spine-cpp/include/spine/Debug.h

@@ -110,7 +110,15 @@ namespace spine {
 		}
 
 		virtual char *_readFile(const String &path, int *length) {
-			return _extension->_readFile(path, length);
+            auto data = _extension->_readFile(path, length);
+
+            if (_allocated.count(data) == 0) {
+                _allocated[data] = Allocation(data, sizeof(char) * (*length), nullptr, 0);
+                _allocations++;
+                _usedMemory += sizeof(char) * (*length);
+            }
+
+            return data;
 		}
 
 		size_t getUsedMemory() {