瀏覽代碼

Merge pull request #4898 from alektron/ArenaTotalUsedMismatch

Invalid virtual arena state after resize
gingerBill 6 月之前
父節點
當前提交
4b2b49dc30
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      core/mem/virtual/arena.odin

+ 2 - 0
core/mem/virtual/arena.odin

@@ -341,7 +341,9 @@ arena_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode,
 				new_end := start + size
 				new_end := start + size
 				if start < old_end && old_end == block.used && new_end <= block.reserved {
 				if start < old_end && old_end == block.used && new_end <= block.reserved {
 					// grow data in-place, adjusting next allocation
 					// grow data in-place, adjusting next allocation
+					prev_used := block.used
 					_ = alloc_from_memory_block(block, new_end - old_end, 1, default_commit_size=arena.default_commit_size) or_return
 					_ = alloc_from_memory_block(block, new_end - old_end, 1, default_commit_size=arena.default_commit_size) or_return
+					arena.total_used += block.used - prev_used
 					data = block.base[start:new_end]
 					data = block.base[start:new_end]
 					return
 					return
 				}
 				}