diff --git a/code/api.odin b/code/api.odin index 40bfc20..8c94c94 100644 --- a/code/api.odin +++ b/code/api.odin @@ -155,7 +155,7 @@ startup :: proc( persistent_mem, frame_mem, transient_mem, files_buffer_mem : ^V // } // Setup workspace UI state - ui_startup( & workspace.ui, persistent_allocator() ) + ui_startup( & workspace.ui, cache_allocator = general_slab_allocator() ) } } } @@ -201,7 +201,7 @@ reload :: proc( persistent_mem, frame_mem, transient_mem, files_buffer_mem : ^VA // font_provide_data.font_cache.hashes.allocator = slab_allocator() // font_provide_data.font_cache.entries.allocator = slab_allocator() - ui_reload( & get_state().project.workspace.ui, persistent_allocator() ) + ui_reload( & get_state().project.workspace.ui, cache_allocator = general_slab_allocator() ) log("Module reloaded") } diff --git a/code/grime_filesystem.odin b/code/grime_filesystem.odin index 52205f9..2016336 100644 --- a/code/grime_filesystem.odin +++ b/code/grime_filesystem.odin @@ -5,11 +5,11 @@ import "core:fmt" import "core:os" import "core:runtime" -file_copy_sync :: proc( path_src, path_dst: string ) -> b32 +file_copy_sync :: proc( path_src, path_dst: string, allocator := context.temp_allocator ) -> b32 { file_size : i64 { - path_info, result := file_status( path_src, context.temp_allocator ) + path_info, result := file_status( path_src, allocator ) if result != os.ERROR_NONE { logf("Could not get file info: %v", result, LogLevel.Error ) return false @@ -17,7 +17,7 @@ file_copy_sync :: proc( path_src, path_dst: string ) -> b32 file_size = path_info.size } - src_content, result := os.read_entire_file( path_src, context.temp_allocator ) + src_content, result := os.read_entire_file( path_src, allocator ) if ! result { logf( "Failed to read file to copy: %v", path_src, LogLevel.Error ) runtime.debug_trap() @@ -34,7 +34,7 @@ file_copy_sync :: proc( path_src, path_dst: string ) -> b32 } file_exists :: proc( file_path : string ) -> b32 { - path_info, result := file_status( file_path, context.temp_allocator ) + path_info, result := file_status( file_path, frame_allocator() ) if result != os.ERROR_NONE { return false } diff --git a/code/grime_pool_allocator.odin b/code/grime_pool_allocator.odin index fed15aa..bdcea04 100644 --- a/code/grime_pool_allocator.odin +++ b/code/grime_pool_allocator.odin @@ -64,7 +64,9 @@ pool_init :: proc ( if alloc_error != .None do return pool.header = cast( ^PoolHeader) raw_mem + pool.backing = allocator pool.block_size = block_size + pool.bucket_capacity = bucket_capacity pool.alignment = alignment if bucket_reserve_num > 0 { @@ -93,8 +95,7 @@ pool_allocate_buckets :: proc( using self : Pool, num_buckets : uint ) -> Alloca return .Invalid_Argument } header_size := cast(uint) align_forward_int( size_of(PoolBucket), int(alignment)) - bucket_size := block_size * bucket_capacity - to_allocate := cast(int) (header_size + bucket_size * num_buckets) + to_allocate := cast(int) (header_size + bucket_capacity * num_buckets) bucket_memory, alloc_error := alloc( to_allocate, int(alignment), backing ) if alloc_error != .None { @@ -107,9 +108,16 @@ pool_allocate_buckets :: proc( using self : Pool, num_buckets : uint ) -> Alloca bucket := cast( ^PoolBucket) next_bucket_ptr bucket.blocks = memory_after_header(bucket) bucket.next_block = 0 - dll_push_back( & self.bucket_list.last, bucket ) - next_bucket_ptr = next_bucket_ptr[ bucket_size: ] + if self.bucket_list.first == nil { + self.bucket_list.first = bucket + self.bucket_list.last = bucket + } + else { + dll_push_back( & self.bucket_list.last, bucket ) + } + + next_bucket_ptr = next_bucket_ptr[ bucket_capacity: ] } return alloc_error } diff --git a/code/ui.odin b/code/ui.odin index 85633ac..a76cfc0 100644 --- a/code/ui.odin +++ b/code/ui.odin @@ -248,7 +248,7 @@ UI_Box :: struct { UI_Layout_Stack_Size :: 512 UI_Style_Stack_Size :: 512 UI_Parent_Stack_Size :: 1024 -UI_Built_Boxes_Array_Size :: Kilobyte * 8 +UI_Built_Boxes_Array_Size :: 128 UI_State :: struct { // TODO(Ed) : Use these