diff options
| author | gingerBill <bill@gingerbill.org> | 2020-09-15 11:52:19 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-09-15 11:52:19 +0100 |
| commit | f48a8739546cbe2e7efc153f6f1cd2f20d1733a8 (patch) | |
| tree | 6876ef31b37837a918e8e93381d41c13cd91a8ed /core/runtime/default_allocators.odin | |
| parent | 4930a9c1a49ea2e0d7c286812f3e64cc08e1eb23 (diff) | |
Reorganize package runtime
Separates out the OS specific stuff into different files
Diffstat (limited to 'core/runtime/default_allocators.odin')
| -rw-r--r-- | core/runtime/default_allocators.odin | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/core/runtime/default_allocators.odin b/core/runtime/default_allocators.odin index 14f4edcda..7e616d043 100644 --- a/core/runtime/default_allocators.odin +++ b/core/runtime/default_allocators.odin @@ -1,14 +1,32 @@ package runtime -import "core:os" +when ODIN_OS == "freestanding" { + // mem.nil_allocator reimplementation -default_allocator_proc :: os.heap_allocator_proc; + default_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode, + size, alignment: int, + old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> rawptr { + return nil; + } + + default_allocator :: proc() -> Allocator { + return Allocator{ + procedure = default_allocator_proc, + data = nil, + }; + } +} else { + import "core:os" -default_allocator :: proc() -> Allocator { - return os.heap_allocator(); + default_allocator_proc :: os.heap_allocator_proc; + + default_allocator :: proc() -> Allocator { + return os.heap_allocator(); + } } + Default_Temp_Allocator :: struct { data: []byte, curr_offset: int, |