Fixed scratch init problem

This commit is contained in:
Allen Webster 2019-10-01 14:14:56 -07:00
parent c0c536651e
commit 7b97bd7105
1 changed files with 6 additions and 2 deletions

View File

@ -2619,21 +2619,25 @@ scratch_block__init(Scratch_Block *block, Arena *arena){
block->arena = arena; block->arena = arena;
block->temp = begin_temp(arena); block->temp = begin_temp(arena);
block->do_full_clear = false; block->do_full_clear = false;
block->tctx = 0;
block->sharable_restore = 0;
} }
internal void internal void
scratch_block__init(Scratch_Block *block, Thread_Context *tctx, Scratch_Share_Code share){ scratch_block__init(Scratch_Block *block, Thread_Context *tctx, Scratch_Share_Code share){
block->tctx = tctx;
Arena *arena = tctx->sharable_scratch; Arena *arena = tctx->sharable_scratch;
if (arena != 0){ if (arena != 0){
block->arena = arena;
block->temp = begin_temp(arena); block->temp = begin_temp(arena);
block->do_full_clear = false; block->do_full_clear = false;
} }
else{ else{
arena = reserve_arena(tctx); arena = reserve_arena(tctx);
block->arena = arena;
block_zero_struct(&block->temp);
block->do_full_clear = true; block->do_full_clear = true;
} }
block->arena = arena; block->tctx = tctx;
block->sharable_restore = tctx->sharable_scratch; block->sharable_restore = tctx->sharable_scratch;
if (share == Scratch_Share){ if (share == Scratch_Share){
tctx->sharable_scratch = arena; tctx->sharable_scratch = arena;