From 4484a3433d6c58f1d1c594a4c36317f323cb5102 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 31 Mar 2022 15:03:56 +0100 Subject: [PATCH] Update `mem.nil_allocator` to match the same in `runtime` --- core/mem/allocators.odin | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/mem/allocators.odin b/core/mem/allocators.odin index b8bd9a065..4954122ed 100644 --- a/core/mem/allocators.odin +++ b/core/mem/allocators.odin @@ -6,7 +6,24 @@ import "core:runtime" nil_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode, size, alignment: int, old_memory: rawptr, old_size: int, loc := #caller_location) -> ([]byte, Allocator_Error) { - return nil, nil + switch mode { + case .Alloc: + return nil, .Out_Of_Memory + case .Free: + return nil, .None + case .Free_All: + return nil, .Mode_Not_Implemented + case .Resize: + if size == 0 { + return nil, .None + } + return nil, .Out_Of_Memory + case .Query_Features: + return nil, .Mode_Not_Implemented + case .Query_Info: + return nil, .Mode_Not_Implemented + } + return nil, .None } nil_allocator :: proc() -> Allocator {