mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-13 01:21:38 -07:00
Removed implicit assignments for container allocators in the Base and Core packages
This commit is contained in:
@@ -786,9 +786,10 @@ _reserve_dynamic_array :: #force_inline proc(a: ^Raw_Dynamic_Array, size_of_elem
|
||||
return nil
|
||||
}
|
||||
|
||||
if a.allocator.procedure == nil {
|
||||
a.allocator = context.allocator
|
||||
}
|
||||
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
|
||||
// if a.allocator.procedure == nil {
|
||||
// a.allocator = context.allocator
|
||||
// }
|
||||
assert(a.allocator.procedure != nil)
|
||||
|
||||
old_size := a.cap * size_of_elem
|
||||
@@ -836,9 +837,10 @@ _resize_dynamic_array :: #force_inline proc(a: ^Raw_Dynamic_Array, size_of_elem,
|
||||
return nil
|
||||
}
|
||||
|
||||
if a.allocator.procedure == nil {
|
||||
a.allocator = context.allocator
|
||||
}
|
||||
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
|
||||
// if a.allocator.procedure == nil {
|
||||
// a.allocator = context.allocator
|
||||
// }
|
||||
assert(a.allocator.procedure != nil)
|
||||
|
||||
old_size := a.cap * size_of_elem
|
||||
@@ -900,9 +902,10 @@ _shrink_dynamic_array :: proc(a: ^Raw_Dynamic_Array, size_of_elem, align_of_elem
|
||||
return
|
||||
}
|
||||
|
||||
if a.allocator.procedure == nil {
|
||||
a.allocator = context.allocator
|
||||
}
|
||||
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
|
||||
// if a.allocator.procedure == nil {
|
||||
// a.allocator = context.allocator
|
||||
// }
|
||||
assert(a.allocator.procedure != nil)
|
||||
|
||||
old_size := a.cap * size_of_elem
|
||||
|
||||
@@ -102,10 +102,11 @@ make_soa_aligned :: proc($T: typeid/#soa[]$E, #any_int length, alignment: int, a
|
||||
total_size = align_forward_int(total_size, max_align)
|
||||
}
|
||||
|
||||
allocator := allocator
|
||||
if allocator.procedure == nil {
|
||||
allocator = context.allocator
|
||||
}
|
||||
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
|
||||
// allocator := allocator
|
||||
// if allocator.procedure == nil {
|
||||
// allocator = context.allocator
|
||||
// }
|
||||
assert(allocator.procedure != nil)
|
||||
|
||||
new_bytes: []byte
|
||||
@@ -215,9 +216,10 @@ _reserve_soa :: proc(array: ^$T/#soa[dynamic]$E, capacity: int, zero_memory: boo
|
||||
return nil
|
||||
}
|
||||
|
||||
if array.allocator.procedure == nil {
|
||||
array.allocator = context.allocator
|
||||
}
|
||||
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
|
||||
// if array.allocator.procedure == nil {
|
||||
// array.allocator = context.allocator
|
||||
// }
|
||||
assert(array.allocator.procedure != nil)
|
||||
|
||||
footer := raw_soa_footer(array)
|
||||
|
||||
@@ -113,9 +113,10 @@ arena_alloc :: proc(arena: ^Arena, size, alignment: uint, loc := #caller_locatio
|
||||
|
||||
block_size := max(needed, arena.minimum_block_size)
|
||||
|
||||
if arena.backing_allocator.procedure == nil {
|
||||
arena.backing_allocator = default_allocator()
|
||||
}
|
||||
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
|
||||
// if arena.backing_allocator.procedure == nil {
|
||||
// arena.backing_allocator = default_allocator()
|
||||
// }
|
||||
|
||||
new_block := memory_block_alloc(arena.backing_allocator, block_size, alignment, loc) or_return
|
||||
new_block.prev = arena.curr_block
|
||||
|
||||
@@ -16,9 +16,11 @@ __dynamic_array_reserve :: proc(array_: rawptr, elem_size, elem_align: int, cap:
|
||||
|
||||
// NOTE(tetra, 2020-01-26): We set the allocator before earlying-out below, because user code is usually written
|
||||
// assuming that appending/reserving will set the allocator, if it is not already set.
|
||||
if array.allocator.procedure == nil {
|
||||
array.allocator = context.allocator
|
||||
}
|
||||
|
||||
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
|
||||
// if array.allocator.procedure == nil {
|
||||
// array.allocator = context.allocator
|
||||
// }
|
||||
assert(array.allocator.procedure != nil)
|
||||
|
||||
if cap <= array.cap {
|
||||
@@ -50,9 +52,11 @@ __dynamic_array_shrink :: proc(array_: rawptr, elem_size, elem_align: int, new_c
|
||||
|
||||
// NOTE(tetra, 2020-01-26): We set the allocator before earlying-out below, because user code is usually written
|
||||
// assuming that appending/reserving will set the allocator, if it is not already set.
|
||||
if array.allocator.procedure == nil {
|
||||
array.allocator = context.allocator
|
||||
}
|
||||
|
||||
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
|
||||
// if array.allocator.procedure == nil {
|
||||
// array.allocator = context.allocator
|
||||
// }
|
||||
assert(array.allocator.procedure != nil)
|
||||
|
||||
if new_cap > array.cap {
|
||||
|
||||
@@ -587,9 +587,11 @@ map_reserve_dynamic :: #force_no_inline proc "odin" (#no_alias m: ^Raw_Map, #no_
|
||||
return size_of(uintptr)*8 - 1 - z
|
||||
}
|
||||
|
||||
if m.allocator.procedure == nil {
|
||||
m.allocator = context.allocator
|
||||
}
|
||||
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
|
||||
// if m.allocator.procedure == nil {
|
||||
// m.allocator = context.allocator
|
||||
// }
|
||||
assert( m.allocator.procedure != nil)
|
||||
|
||||
new_capacity := new_capacity
|
||||
old_capacity := uintptr(map_cap(m^))
|
||||
@@ -642,9 +644,11 @@ map_reserve_dynamic :: #force_no_inline proc "odin" (#no_alias m: ^Raw_Map, #no_
|
||||
|
||||
@(require_results)
|
||||
map_shrink_dynamic :: #force_no_inline proc "odin" (#no_alias m: ^Raw_Map, #no_alias info: ^Map_Info, loc := #caller_location) -> (did_shrink: bool, err: Allocator_Error) {
|
||||
if m.allocator.procedure == nil {
|
||||
m.allocator = context.allocator
|
||||
}
|
||||
// Note(Ed) - Sectr Fork: Not a fan. (I want it to assert)
|
||||
// if m.allocator.procedure == nil {
|
||||
// m.allocator = context.allocator
|
||||
// }
|
||||
assert( m.allocator.procedure != nil)
|
||||
|
||||
// Cannot shrink the capacity if the number of items in the map would exceed
|
||||
// one minus the current log2 capacity's resize threshold. That is the shrunk
|
||||
|
||||
Reference in New Issue
Block a user