aboutsummaryrefslogtreecommitdiff
path: root/core/runtime/default_allocators_windows.odin
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-06-08 11:20:39 +0100
committergingerBill <bill@gingerbill.org>2021-06-08 11:20:39 +0100
commit16eaa17ed988e8a04cc75d8aae3cdea4bd56ad9d (patch)
tree3a3298da10da8446d289c3294089d7ab587e7ce4 /core/runtime/default_allocators_windows.odin
parent9491c13a5c967ff0fa6d5ce3c330dcbf13888d6c (diff)
Fix `-target:js_wasm32` for `core:runtime`
Diffstat (limited to 'core/runtime/default_allocators_windows.odin')
-rw-r--r--core/runtime/default_allocators_windows.odin39
1 files changed, 39 insertions, 0 deletions
diff --git a/core/runtime/default_allocators_windows.odin b/core/runtime/default_allocators_windows.odin
new file mode 100644
index 000000000..64b2dd23e
--- /dev/null
+++ b/core/runtime/default_allocators_windows.odin
@@ -0,0 +1,39 @@
+//+build windows
+package runtime
+
+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,
+ };
+}