diff --git a/project/components/interface.untyped.cpp b/project/components/interface.untyped.cpp index 9eacf1b..b16e48c 100644 --- a/project/components/interface.untyped.cpp +++ b/project/components/interface.untyped.cpp @@ -16,8 +16,8 @@ ssize token_fmt_va( char* buf, usize buf_size, s32 num_tokens, va_list va ) local_persist char tok_map_mem[ TokenFmt_TokenMap_MemSize ]; - tok_map_arena = Arena::init_from_memory( tok_map_mem, sizeof(tok_map_mem) ); - tok_map = HashTable::init( tok_map_arena ); + init_from_memory( tok_map_arena, tok_map_mem, sizeof(tok_map_mem) ); + tok_map = HashTable::init( tok_map_arena ); s32 left = num_tokens - 1; diff --git a/project/components/parser.cpp b/project/components/parser.cpp index 796a182..9be9027 100644 --- a/project/components/parser.cpp +++ b/project/components/parser.cpp @@ -712,7 +712,10 @@ Code parse_class_struct( TokType which, bool inplace_def = false ) local_persist char interface_arr_mem[ kilobytes(4) ] {0}; - Array interfaces = Array::init_reserve( Arena::init_from_memory(interface_arr_mem, kilobytes(4) ), 4 ); + Array interfaces; { + Arena arena; init_from_memory(arena, interface_arr_mem, kilobytes(4) ); + Array::init_reserve( arena, 4 ); + } // TODO(Ed) : Make an AST_DerivedType, we'll store any arbitary derived type into there as a linear linked list of them. if ( check( TokType::Assign_Classifer ) ) diff --git a/project/dependencies/memory.hpp b/project/dependencies/memory.hpp index 889749b..a327ba9 100644 --- a/project/dependencies/memory.hpp +++ b/project/dependencies/memory.hpp @@ -170,23 +170,20 @@ b32 gen_vm_purge( VirtualMemory vm ); //! Retrieve VM's page size and alignment. ssize gen_virtual_memory_page_size( ssize* alignment_out ); + +struct Arena; +void init_from_memory( Arena& arena, void* start, ssize size ); + struct Arena { static void* allocator_proc( void* allocator_data, AllocType type, ssize size, ssize alignment, void* old_memory, ssize old_size, u64 flags ); - static - Arena init_from_memory( void* start, ssize size ) - { - return - { - { nullptr, nullptr }, - start, - size, - 0, - 0 - }; - } + //forceinline static + //Arena init_from_memory( void* start, ssize size ) { + // Arena result; GEN_NS init_from_memory( result, start, size ); + // return result; + //} static Arena init_from_allocator( AllocatorInfo backing, ssize size ) @@ -249,16 +246,25 @@ struct Arena AllocatorInfo Backing; void* PhysicalStart; - ssize TotalSize; - ssize TotalUsed; - ssize TempCount; + ssize TotalSize; + ssize TotalUsed; + ssize TempCount; - operator AllocatorInfo() - { - return { allocator_proc, this }; - } + operator AllocatorInfo() { return { allocator_proc, this }; } }; +void init_from_memory( Arena& arena, void* start, ssize size ) +{ + arena = + { + { nullptr, nullptr }, + start, + size, + 0, + 0 + }; +} + // Just a wrapper around using an arena with memory associated with its scope instead of from an allocator. // Used for static segment or stack allocations. template< s32 Size >