From 53e84b7f31a218102034c60e157b60d22adcf303 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 19 Oct 2022 23:39:47 +0100 Subject: [PATCH] Remove doubly linked list of `Platform_Memory_Block` fields --- core/mem/virtual/virtual.odin | 12 ------------ core/mem/virtual/virtual_platform.odin | 25 ------------------------- 2 files changed, 37 deletions(-) diff --git a/core/mem/virtual/virtual.odin b/core/mem/virtual/virtual.odin index 426482fff..c4a475dba 100644 --- a/core/mem/virtual/virtual.odin +++ b/core/mem/virtual/virtual.odin @@ -96,13 +96,6 @@ memory_block_alloc :: proc(committed, reserved: uint, flags: Memory_Block_Flags) pmblock.block.committed = committed pmblock.block.reserved = reserved - sentinel := &global_platform_memory_block_sentinel - platform_mutex_lock() - pmblock.next = sentinel - pmblock.prev = sentinel.prev - pmblock.prev.next = pmblock - pmblock.next.prev = pmblock - platform_mutex_unlock() return &pmblock.block, nil } @@ -157,11 +150,6 @@ alloc_from_memory_block :: proc(block: ^Memory_Block, min_size, alignment: uint) memory_block_dealloc :: proc(block_to_free: ^Memory_Block) { if block := (^Platform_Memory_Block)(block_to_free); block != nil { - platform_mutex_lock() - block.prev.next = block.next - block.next.prev = block.prev - platform_mutex_unlock() - platform_memory_free(block) } } diff --git a/core/mem/virtual/virtual_platform.odin b/core/mem/virtual/virtual_platform.odin index 2f167cbeb..c2b505cd2 100644 --- a/core/mem/virtual/virtual_platform.odin +++ b/core/mem/virtual/virtual_platform.odin @@ -1,13 +1,10 @@ //+private package mem_virtual -import "core:sync" - Platform_Memory_Block :: struct { block: Memory_Block, committed: uint, reserved: uint, - prev, next: ^Platform_Memory_Block, } platform_memory_alloc :: proc "contextless" (to_commit, to_reserve: uint) -> (block: ^Platform_Memory_Block, err: Allocator_Error) { @@ -33,28 +30,6 @@ platform_memory_free :: proc "contextless" (block: ^Platform_Memory_Block) { } } -platform_mutex_lock :: proc() { - sync.mutex_lock(&global_memory_block_mutex) -} - -platform_mutex_unlock :: proc() { - sync.mutex_unlock(&global_memory_block_mutex) -} - -global_memory_block_mutex: sync.Mutex -global_platform_memory_block_sentinel: Platform_Memory_Block -global_platform_memory_block_sentinel_set: bool - -@(init) -platform_memory_init :: proc() { - if !global_platform_memory_block_sentinel_set { - _platform_memory_init() - global_platform_memory_block_sentinel.prev = &global_platform_memory_block_sentinel - global_platform_memory_block_sentinel.next = &global_platform_memory_block_sentinel - global_platform_memory_block_sentinel_set = true - } -} - platform_memory_commit :: proc "contextless" (block: ^Platform_Memory_Block, to_commit: uint) -> (err: Allocator_Error) { if to_commit < block.committed { return nil