Fixed crash in arena_free_all() for bootstrapped growing arenas.

When trying to set arena.curr_block.used = 0 after mem.zero() caused a crash because if the arena is bootstrapped its memory will be zeroed out after mem.zero() thus making arena.cur_block point to zero.
This commit is contained in:
dmitriy.gorevoy
2024-12-23 09:25:18 +01:00
parent 597fba7c31
commit e82a0c8fc7

View File

@@ -204,8 +204,9 @@ arena_free_all :: proc(arena: ^Arena, loc := #caller_location) {
}
// Zero the first block's memory
if arena.curr_block != nil {
mem.zero(arena.curr_block.base, int(arena.curr_block.used))
curr_block_used := int(arena.curr_block.used)
arena.curr_block.used = 0
mem.zero(arena.curr_block.base, curr_block_used)
}
arena.total_used = 0
case .Static, .Buffer: