Disable constants inside structures

This commit is contained in:
Krzosa Karol
2022-09-27 10:26:33 +02:00
parent fef98220ba
commit 3dd9fae080
3 changed files with 46 additions and 45 deletions

View File

@@ -2,16 +2,16 @@ Os :: #import "os_windows.kl"
SizeU :: U64
arena_di: U64
ADDITIONAL_COMMIT_SIZE :: 1024*1024
DEFAULT_RESERVE_SIZE :: 1024*1024*1024
DEFAULT_ALIGNMENT :: 8
Arena :: struct
di: U64 // @debug_id
memory: Os.Memory
alignment: U64
len: U64
ADDITIONAL_COMMIT_SIZE :: 1024*1024
DEFAULT_RESERVE_SIZE :: 1024*1024*1024
DEFAULT_ALIGNMENT :: 8
clamp_top_sizeu :: (val: SizeU, max: SizeU): SizeU
if val > max
return max
@@ -29,8 +29,8 @@ align_up :: (size: SizeU, align: SizeU): SizeU
return result
arena_init :: (a: *Arena)
a.memory = Os.reserve(a.DEFAULT_RESERVE_SIZE)
a.alignment = a.DEFAULT_ALIGNMENT
a.memory = Os.reserve(DEFAULT_RESERVE_SIZE)
a.alignment = DEFAULT_ALIGNMENT
a.di = arena_di++
// a.allocator.proc = arena_allocator_proc
@@ -39,7 +39,7 @@ arena_push_size :: (a: *Arena, size: SizeU): *void
if a.len + generous_size > a.memory.commit
if a.memory.reserve == 0
arena_init(a)
result := Os.commit(&a.memory, generous_size + a.ADDITIONAL_COMMIT_SIZE)
result := Os.commit(&a.memory, generous_size + ADDITIONAL_COMMIT_SIZE)
assert(result == true)
a.len = align_up(a.len, a.alignment)
assert(a.memory.reserve > a.len + a.memory.commit)