aboutsummaryrefslogtreecommitdiff
path: root/base/runtime
diff options
context:
space:
mode:
authorDamian Tarnawski <gthetarnav@gmail.com>2025-09-02 13:03:15 +0200
committerDamian Tarnawski <gthetarnav@gmail.com>2025-09-02 13:03:15 +0200
commit21fd7c200e95dbbf3e6f5ba3d203c3056db9df65 (patch)
treebe8481b51d07d6b0d82f8bf0aa801fe13218198a /base/runtime
parent7e3e15aee6905839f85a0da259977a4c41c997b4 (diff)
Add require_results attr to procs returning an allocator
Diffstat (limited to 'base/runtime')
-rw-r--r--base/runtime/default_allocators_nil.odin2
-rw-r--r--base/runtime/default_temp_allocator_arena.odin1
-rw-r--r--base/runtime/default_temporary_allocator.odin2
-rw-r--r--base/runtime/heap_allocator.odin1
-rw-r--r--base/runtime/wasm_allocator.odin2
5 files changed, 7 insertions, 1 deletions
diff --git a/base/runtime/default_allocators_nil.odin b/base/runtime/default_allocators_nil.odin
index 14edd11dd..f5ebad28f 100644
--- a/base/runtime/default_allocators_nil.odin
+++ b/base/runtime/default_allocators_nil.odin
@@ -23,6 +23,7 @@ nil_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
return nil, .None
}
+@(require_results)
nil_allocator :: proc "contextless" () -> Allocator {
return Allocator{
procedure = nil_allocator_proc,
@@ -72,6 +73,7 @@ panic_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
return nil, nil
}
+@(require_results)
panic_allocator :: proc() -> Allocator {
return Allocator{
procedure = panic_allocator_proc,
diff --git a/base/runtime/default_temp_allocator_arena.odin b/base/runtime/default_temp_allocator_arena.odin
index 525f81825..8f4821b4a 100644
--- a/base/runtime/default_temp_allocator_arena.odin
+++ b/base/runtime/default_temp_allocator_arena.odin
@@ -187,6 +187,7 @@ arena_destroy :: proc "contextless" (arena: ^Arena, loc := #caller_location) {
arena.total_capacity = 0
}
+@(require_results)
arena_allocator :: proc(arena: ^Arena) -> Allocator {
return Allocator{arena_allocator_proc, arena}
}
diff --git a/base/runtime/default_temporary_allocator.odin b/base/runtime/default_temporary_allocator.odin
index 671728be8..ec3c6ad8c 100644
--- a/base/runtime/default_temporary_allocator.odin
+++ b/base/runtime/default_temporary_allocator.odin
@@ -70,7 +70,7 @@ DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD :: #force_inline proc(ignore := false, loc :=
}
}
-
+@(require_results)
default_temp_allocator :: proc(allocator: ^Default_Temp_Allocator) -> Allocator {
return Allocator{
procedure = default_temp_allocator_proc,
diff --git a/base/runtime/heap_allocator.odin b/base/runtime/heap_allocator.odin
index 4b04dffef..f2c887759 100644
--- a/base/runtime/heap_allocator.odin
+++ b/base/runtime/heap_allocator.odin
@@ -2,6 +2,7 @@ package runtime
import "base:intrinsics"
+@(require_results)
heap_allocator :: proc() -> Allocator {
return Allocator{
procedure = heap_allocator_proc,
diff --git a/base/runtime/wasm_allocator.odin b/base/runtime/wasm_allocator.odin
index 574f3dd06..325b1d4fa 100644
--- a/base/runtime/wasm_allocator.odin
+++ b/base/runtime/wasm_allocator.odin
@@ -89,10 +89,12 @@ wasm_allocator_init :: proc(a: ^WASM_Allocator, alignment: uint = 8) {
global_default_wasm_allocator_data: WASM_Allocator
+@(require_results)
default_wasm_allocator :: proc() -> Allocator {
return wasm_allocator(&global_default_wasm_allocator_data)
}
+@(require_results)
wasm_allocator :: proc(a: ^WASM_Allocator) -> Allocator {
return {
data = a,