浏览代码

express: Fix track-memory-usage with DeletedBufferChain off

mark_pointer gets called twice, which is now legal
rdb 3 月之前
父节点
当前提交
557ce7a841
共有 1 个文件被更改,包括 10 次插入5 次删除
  1. 10 5
      panda/src/express/memoryUsage.cxx

+ 10 - 5
panda/src/express/memoryUsage.cxx

@@ -826,7 +826,8 @@ ns_record_void_pointer(void *ptr, size_t size) {
   if (_track_memory_usage) {
     if (express_cat.is_spam()) {
       express_cat.spam()
-        << "Recording void pointer " << (void *)ptr << "\n";
+        << "Recording void pointer " << (void *)ptr
+        << " with size " << size << "\n";
     }
 
     // We have to protect modifications to the table from recursive calls by
@@ -846,11 +847,15 @@ ns_record_void_pointer(void *ptr, size_t size) {
 
     MemoryInfo *info = (*insert_result.first).second;
 
-    // We shouldn't already have a void pointer.
+    // If we already have a void pointer, that's okay, as long as the size
+    // matches.
     if (info->_void_ptr != nullptr) {
-      express_cat.error()
-        << "Void pointer " << (void *)ptr << " recorded twice!\n";
-      nassertv(false);
+      if (info->_size != size) {
+        express_cat.error()
+          << "Void pointer " << (void *)ptr
+          << " was already recorded with size " << size << "!\n";
+        nassertv(false);
+      }
     }
 
     if (info->_freeze_index == _freeze_index) {