Refactor decommit to arena_trim
This commit is contained in:
+13
-6
@@ -128,12 +128,7 @@ void arena_reset_to(Arena *arena, U64 total_offset)
|
||||
ASAN_POISON_MEMORY_REGION(&block->base[block->first_free], memoryblock_available(block));
|
||||
|
||||
if ((arena->flags & ArenaFlag_NoDecommit) == 0) {
|
||||
U32 aligned_pos = RoundUpToMultiple(block->first_free, arena->commit_size);
|
||||
if (aligned_pos < block->committed_end) {
|
||||
ASAN_UNPOISON_MEMORY_REGION(&block->base[aligned_pos], block->committed_end);
|
||||
memory_decommit(&block->base[aligned_pos], block->committed_end - aligned_pos);
|
||||
block->committed_end = aligned_pos;
|
||||
}
|
||||
arena_trim(arena);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -143,6 +138,18 @@ void arena_reset_to(Arena *arena, U64 total_offset)
|
||||
}
|
||||
}
|
||||
|
||||
void arena_trim(Arena *arena)
|
||||
{
|
||||
MemoryBlock *block = arena->current;
|
||||
U32 aligned_pos = RoundUpToMultiple(block->first_free, arena->commit_size);
|
||||
if (aligned_pos < block->committed_end) {
|
||||
void *trim_start = &block->base[aligned_pos];
|
||||
// Note(nos): Should we unpoision ?
|
||||
//ASAN_UNPOISON_MEMORY_REGION(trim_start, block->committed_end);
|
||||
memory_decommit(trim_start, block->committed_end - aligned_pos);
|
||||
block->committed_end = aligned_pos;
|
||||
}
|
||||
}
|
||||
ATemp arena_temp_begin(Arena *arena)
|
||||
{
|
||||
ATemp checkpoint = {};
|
||||
|
||||
Reference in New Issue
Block a user