Merge pull request #3273 from Chickenkeeper/mutex-allocator-fix

Make Mutex_Allocator use Ada_Case
This commit is contained in:
gingerBill
2024-03-13 15:45:52 +00:00
committed by GitHub
+4 -4
View File
@@ -3,19 +3,19 @@ package mem
import "core:sync" import "core:sync"
Mutex_allocator :: struct { Mutex_Allocator :: struct {
backing: Allocator, backing: Allocator,
mutex: sync.Mutex, mutex: sync.Mutex,
} }
mutex_allocator_init :: proc(m: ^Mutex_allocator, backing_allocator: Allocator) { mutex_allocator_init :: proc(m: ^Mutex_Allocator, backing_allocator: Allocator) {
m.backing = backing_allocator m.backing = backing_allocator
m.mutex = {} m.mutex = {}
} }
@(require_results) @(require_results)
mutex_allocator :: proc(m: ^Mutex_allocator) -> Allocator { mutex_allocator :: proc(m: ^Mutex_Allocator) -> Allocator {
return Allocator{ return Allocator{
procedure = mutex_allocator_proc, procedure = mutex_allocator_proc,
data = m, data = m,
@@ -25,7 +25,7 @@ mutex_allocator :: proc(m: ^Mutex_allocator) -> Allocator {
mutex_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, mutex_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
size, alignment: int, size, alignment: int,
old_memory: rawptr, old_size: int, loc := #caller_location) -> (result: []byte, err: Allocator_Error) { old_memory: rawptr, old_size: int, loc := #caller_location) -> (result: []byte, err: Allocator_Error) {
m := (^Mutex_allocator)(allocator_data) m := (^Mutex_Allocator)(allocator_data)
sync.mutex_guard(&m.mutex) sync.mutex_guard(&m.mutex)
return m.backing.procedure(m.backing.data, mode, size, alignment, old_memory, old_size, loc) return m.backing.procedure(m.backing.data, mode, size, alignment, old_memory, old_size, loc)