瀏覽代碼

Fix very subtle bug in `virtual.memory_block_alloc`

gingerBill 6 天之前
父節點
當前提交
0dd0a3813b
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      core/mem/virtual/virtual.odin

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

@@ -89,8 +89,8 @@ memory_block_alloc :: proc(committed, reserved: uint, alignment: uint = 0, flags
 	reserved  = align_formula(reserved, page_size)
 	committed = clamp(committed, 0, reserved)
 	
-	total_size     := uint(reserved + max(alignment, size_of(Platform_Memory_Block)))
-	base_offset    := uintptr(max(alignment, size_of(Platform_Memory_Block)))
+	total_size     := reserved + alignment + size_of(Platform_Memory_Block)
+	base_offset    := mem.align_forward_uintptr(size_of(Platform_Memory_Block), max(uintptr(alignment), align_of(Platform_Memory_Block)))
 	protect_offset := uintptr(0)
 	
 	do_protection := false