diff options
| author | gingerBill <bill@gingerbill.org> | 2021-05-23 12:13:13 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-05-23 12:13:13 +0100 |
| commit | 71cfa0c9fe3ae50e228aaeee28b163cbcfe10b96 (patch) | |
| tree | 6ecf4f0af5acf4e161b3683acaad1a42aecc9d33 /core/runtime/default_allocators.odin | |
| parent | e82f8214e81e87f337d75c76ae0606a07e51afa0 (diff) | |
Clean up organization of `package runtime`
Diffstat (limited to 'core/runtime/default_allocators.odin')
| -rw-r--r-- | core/runtime/default_allocators.odin | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/core/runtime/default_allocators.odin b/core/runtime/default_allocators.odin index b47e60659..7d13f2a32 100644 --- a/core/runtime/default_allocators.odin +++ b/core/runtime/default_allocators.odin @@ -15,7 +15,46 @@ when ODIN_DEFAULT_TO_NIL_ALLOCATOR || ODIN_OS == "freestanding" { data = nil, }; } -} else when ODIN_OS != "windows" { + +} else when ODIN_OS == "windows" { + default_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, + size, alignment: int, + old_memory: rawptr, old_size: int, loc := #caller_location) -> ([]byte, Allocator_Error) { + switch mode { + case .Alloc: + return _windows_default_alloc(size, alignment); + + case .Free: + _windows_default_free(old_memory); + + case .Free_All: + // NOTE(tetra): Do nothing. + + case .Resize: + return _windows_default_resize(old_memory, old_size, size, alignment); + + case .Query_Features: + set := (^Allocator_Mode_Set)(old_memory); + if set != nil { + set^ = {.Alloc, .Free, .Resize, .Query_Features}; + } + return nil, nil; + + case .Query_Info: + return nil, nil; + } + + return nil, nil; + } + + default_allocator :: proc() -> Allocator { + return Allocator{ + procedure = default_allocator_proc, + data = nil, + }; + } + +} else { // TODO(bill): reimplement these procedures in the os_specific stuff import "core:os" |