diff options
| author | gingerBill <bill@gingerbill.org> | 2022-09-12 13:08:32 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-09-12 13:08:32 +0100 |
| commit | ef372bd86194a01f6386fd1eae71e7362e28cf89 (patch) | |
| tree | f418c4493ab2d0d23c12f05c47bf5e53ce7d7126 /core/runtime | |
| parent | fbbfe438dc8d841bdba6585c7b80336b569a01f0 (diff) | |
Replace `#optional_second` with `#optional_allocator_error`
Diffstat (limited to 'core/runtime')
| -rw-r--r-- | core/runtime/core_builtin.odin | 16 | ||||
| -rw-r--r-- | core/runtime/core_builtin_soa.odin | 4 |
2 files changed, 10 insertions, 10 deletions
diff --git a/core/runtime/core_builtin.odin b/core/runtime/core_builtin.odin index e3960088d..4c736b6f6 100644 --- a/core/runtime/core_builtin.odin +++ b/core/runtime/core_builtin.odin @@ -189,7 +189,7 @@ delete :: proc{ // The new built-in procedure allocates memory. The first argument is a type, not a value, and the value // return is a pointer to a newly allocated value of that type using the specified allocator, default is context.allocator @builtin -new :: proc($T: typeid, allocator := context.allocator, loc := #caller_location) -> (^T, Allocator_Error) #optional_second { +new :: proc($T: typeid, allocator := context.allocator, loc := #caller_location) -> (^T, Allocator_Error) #optional_allocator_error { return new_aligned(T, align_of(T), allocator, loc) } new_aligned :: proc($T: typeid, alignment: int, allocator := context.allocator, loc := #caller_location) -> (t: ^T, err: Allocator_Error) { @@ -199,7 +199,7 @@ new_aligned :: proc($T: typeid, alignment: int, allocator := context.allocator, } @builtin -new_clone :: proc(data: $T, allocator := context.allocator, loc := #caller_location) -> (t: ^T, err: Allocator_Error) #optional_second { +new_clone :: proc(data: $T, allocator := context.allocator, loc := #caller_location) -> (t: ^T, err: Allocator_Error) #optional_allocator_error { t_data := mem_alloc_bytes(size_of(T), align_of(T), allocator, loc) or_return t = (^T)(raw_data(t_data)) if t != nil { @@ -210,7 +210,7 @@ new_clone :: proc(data: $T, allocator := context.allocator, loc := #caller_locat DEFAULT_RESERVE_CAPACITY :: 16 -make_aligned :: proc($T: typeid/[]$E, #any_int len: int, alignment: int, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) #optional_second { +make_aligned :: proc($T: typeid/[]$E, #any_int len: int, alignment: int, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) #optional_allocator_error { make_slice_error_loc(loc, len) data, err := mem_alloc_bytes(size_of(E)*len, alignment, allocator, loc) if data == nil && size_of(E) != 0 { @@ -221,19 +221,19 @@ make_aligned :: proc($T: typeid/[]$E, #any_int len: int, alignment: int, allocat } @(builtin) -make_slice :: proc($T: typeid/[]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) #optional_second { +make_slice :: proc($T: typeid/[]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) #optional_allocator_error { return make_aligned(T, len, align_of(E), allocator, loc) } @(builtin) -make_dynamic_array :: proc($T: typeid/[dynamic]$E, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) #optional_second { +make_dynamic_array :: proc($T: typeid/[dynamic]$E, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) #optional_allocator_error { return make_dynamic_array_len_cap(T, 0, DEFAULT_RESERVE_CAPACITY, allocator, loc) } @(builtin) -make_dynamic_array_len :: proc($T: typeid/[dynamic]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) #optional_second { +make_dynamic_array_len :: proc($T: typeid/[dynamic]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (T, Allocator_Error) #optional_allocator_error { return make_dynamic_array_len_cap(T, len, len, allocator, loc) } @(builtin) -make_dynamic_array_len_cap :: proc($T: typeid/[dynamic]$E, #any_int len: int, #any_int cap: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_second { +make_dynamic_array_len_cap :: proc($T: typeid/[dynamic]$E, #any_int len: int, #any_int cap: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error { make_dynamic_array_error_loc(loc, len, cap) data := mem_alloc_bytes(size_of(E)*cap, align_of(E), allocator, loc) or_return s := Raw_Dynamic_Array{raw_data(data), len, cap, allocator} @@ -253,7 +253,7 @@ make_map :: proc($T: typeid/map[$K]$E, #any_int cap: int = DEFAULT_RESERVE_CAPAC return m } @(builtin) -make_multi_pointer :: proc($T: typeid/[^]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (mp: T, err: Allocator_Error) #optional_second { +make_multi_pointer :: proc($T: typeid/[^]$E, #any_int len: int, allocator := context.allocator, loc := #caller_location) -> (mp: T, err: Allocator_Error) #optional_allocator_error { make_slice_error_loc(loc, len) data := mem_alloc_bytes(size_of(E)*len, align_of(E), allocator, loc) or_return if data == nil && size_of(E) != 0 { diff --git a/core/runtime/core_builtin_soa.odin b/core/runtime/core_builtin_soa.odin index 077027a9a..a6b356642 100644 --- a/core/runtime/core_builtin_soa.odin +++ b/core/runtime/core_builtin_soa.odin @@ -79,7 +79,7 @@ raw_soa_footer :: proc{ @builtin -make_soa_aligned :: proc($T: typeid/#soa[]$E, length: int, alignment: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_second { +make_soa_aligned :: proc($T: typeid/#soa[]$E, length: int, alignment: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error { if length <= 0 { return } @@ -138,7 +138,7 @@ make_soa_aligned :: proc($T: typeid/#soa[]$E, length: int, alignment: int, alloc } @builtin -make_soa_slice :: proc($T: typeid/#soa[]$E, length: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_second { +make_soa_slice :: proc($T: typeid/#soa[]$E, length: int, allocator := context.allocator, loc := #caller_location) -> (array: T, err: Allocator_Error) #optional_allocator_error { return make_soa_aligned(T, length, align_of(E), allocator, loc) } |