|
@@ -164,8 +164,6 @@ new_clone :: proc(data: $T, allocator := context.allocator, loc := #caller_locat
|
|
return nil, .Out_Of_Memory
|
|
return nil, .Out_Of_Memory
|
|
}
|
|
}
|
|
|
|
|
|
-DEFAULT_RESERVE_CAPACITY :: 16
|
|
|
|
-
|
|
|
|
make_aligned :: proc($T: typeid/[]$E, #any_int len: int, alignment: int, allocator := context.allocator, loc := #caller_location) -> (slice: T, err: Allocator_Error) {
|
|
make_aligned :: proc($T: typeid/[]$E, #any_int len: int, alignment: int, allocator := context.allocator, loc := #caller_location) -> (slice: T, err: Allocator_Error) {
|
|
runtime.make_slice_error_loc(loc, len)
|
|
runtime.make_slice_error_loc(loc, len)
|
|
data := alloc_bytes(size_of(E)*len, alignment, allocator, loc) or_return
|
|
data := alloc_bytes(size_of(E)*len, alignment, allocator, loc) or_return
|
|
@@ -179,7 +177,7 @@ make_slice :: proc($T: typeid/[]$E, #any_int len: int, allocator := context.allo
|
|
return make_aligned(T, len, align_of(E), allocator, loc)
|
|
return make_aligned(T, len, align_of(E), allocator, loc)
|
|
}
|
|
}
|
|
make_dynamic_array :: proc($T: typeid/[dynamic]$E, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) {
|
|
make_dynamic_array :: proc($T: typeid/[dynamic]$E, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) {
|
|
- return make_dynamic_array_len_cap(T, 0, DEFAULT_RESERVE_CAPACITY, allocator, loc)
|
|
|
|
|
|
+ return make_dynamic_array_len_cap(T, 0, 16, allocator, loc)
|
|
}
|
|
}
|
|
make_dynamic_array_len :: proc($T: typeid/[dynamic]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) {
|
|
make_dynamic_array_len :: proc($T: typeid/[dynamic]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) {
|
|
return make_dynamic_array_len_cap(T, len, len, allocator, loc)
|
|
return make_dynamic_array_len_cap(T, len, len, allocator, loc)
|
|
@@ -194,12 +192,12 @@ make_dynamic_array_len_cap :: proc($T: typeid/[dynamic]$E, #any_int len: int, #a
|
|
array = transmute(T)s
|
|
array = transmute(T)s
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-make_map :: proc($T: typeid/map[$K]$E, #any_int cap: int = DEFAULT_RESERVE_CAPACITY, allocator := context.allocator, loc := #caller_location) -> T {
|
|
|
|
|
|
+make_map :: proc($T: typeid/map[$K]$E, #any_int cap: int = 1<<runtime.MAP_MIN_LOG2_CAPACITY, allocator := context.allocator, loc := #caller_location) -> T {
|
|
runtime.make_map_expr_error_loc(loc, cap)
|
|
runtime.make_map_expr_error_loc(loc, cap)
|
|
context.allocator = allocator
|
|
context.allocator = allocator
|
|
|
|
|
|
m: T
|
|
m: T
|
|
- reserve_map(&m, cap)
|
|
|
|
|
|
+ reserve_map(&m, cap, loc)
|
|
return m
|
|
return m
|
|
}
|
|
}
|
|
make_multi_pointer :: proc($T: typeid/[^]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (mp: T, err: Allocator_Error) {
|
|
make_multi_pointer :: proc($T: typeid/[^]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (mp: T, err: Allocator_Error) {
|