mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 12:48:14 +00:00
Remove usage of global_default_temp_allocator_data when there is no default allocator (freestanding, JS or --default-to-nil-allocator)
This commit is contained in:
@@ -621,7 +621,9 @@ __init_context :: proc "contextless" (c: ^Context) {
|
|||||||
c.allocator.data = nil
|
c.allocator.data = nil
|
||||||
|
|
||||||
c.temp_allocator.procedure = default_temp_allocator_proc
|
c.temp_allocator.procedure = default_temp_allocator_proc
|
||||||
c.temp_allocator.data = &global_default_temp_allocator_data
|
when !NO_DEFAULT_TEMP_ALLOCATOR {
|
||||||
|
c.temp_allocator.data = &global_default_temp_allocator_data
|
||||||
|
}
|
||||||
|
|
||||||
when !ODIN_DISABLE_ASSERT {
|
when !ODIN_DISABLE_ASSERT {
|
||||||
c.assertion_failure_proc = default_assertion_failure_proc
|
c.assertion_failure_proc = default_assertion_failure_proc
|
||||||
|
|||||||
@@ -15,11 +15,15 @@ container_of :: #force_inline proc "contextless" (ptr: $P/^$Field_Type, $T: type
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@thread_local global_default_temp_allocator_data: Default_Temp_Allocator
|
when !NO_DEFAULT_TEMP_ALLOCATOR {
|
||||||
|
@thread_local global_default_temp_allocator_data: Default_Temp_Allocator
|
||||||
|
}
|
||||||
|
|
||||||
@builtin
|
@(builtin, disabled=NO_DEFAULT_TEMP_ALLOCATOR)
|
||||||
init_global_temporary_allocator :: proc(size: int, backup_allocator := context.allocator) {
|
init_global_temporary_allocator :: proc(size: int, backup_allocator := context.allocator) {
|
||||||
default_temp_allocator_init(&global_default_temp_allocator_data, size, backup_allocator)
|
when !NO_DEFAULT_TEMP_ALLOCATOR {
|
||||||
|
default_temp_allocator_init(&global_default_temp_allocator_data, size, backup_allocator)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package runtime
|
package runtime
|
||||||
|
|
||||||
DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE: int : #config(DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE, 4 * Megabyte)
|
DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE: int : #config(DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE, 4 * Megabyte)
|
||||||
|
NO_DEFAULT_TEMP_ALLOCATOR: bool : ODIN_OS == .Freestanding || ODIN_OS == .JS || ODIN_DEFAULT_TO_NIL_ALLOCATOR
|
||||||
|
|
||||||
|
when NO_DEFAULT_TEMP_ALLOCATOR {
|
||||||
when ODIN_OS == .Freestanding || ODIN_OS == .JS || ODIN_DEFAULT_TO_NIL_ALLOCATOR {
|
|
||||||
Default_Temp_Allocator :: struct {}
|
Default_Temp_Allocator :: struct {}
|
||||||
|
|
||||||
default_temp_allocator_init :: proc(s: ^Default_Temp_Allocator, size: int, backing_allocator := context.allocator) {}
|
default_temp_allocator_init :: proc(s: ^Default_Temp_Allocator, size: int, backing_allocator := context.allocator) {}
|
||||||
@@ -54,6 +54,11 @@ when ODIN_OS == .Freestanding || ODIN_OS == .JS || ODIN_DEFAULT_TO_NIL_ALLOCATOR
|
|||||||
default_temp_allocator_temp_end :: proc(temp: Arena_Temp, loc := #caller_location) {
|
default_temp_allocator_temp_end :: proc(temp: Arena_Temp, loc := #caller_location) {
|
||||||
arena_temp_end(temp, loc)
|
arena_temp_end(temp, loc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@(fini, private)
|
||||||
|
_destroy_temp_allocator_fini :: proc() {
|
||||||
|
default_temp_allocator_destroy(&global_default_temp_allocator_data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@(deferred_out=default_temp_allocator_temp_end)
|
@(deferred_out=default_temp_allocator_temp_end)
|
||||||
@@ -72,8 +77,3 @@ default_temp_allocator :: proc(allocator: ^Default_Temp_Allocator) -> Allocator
|
|||||||
data = allocator,
|
data = allocator,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@(fini, private)
|
|
||||||
_destroy_temp_allocator_fini :: proc() {
|
|
||||||
default_temp_allocator_destroy(&global_default_temp_allocator_data)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user