Improve the Allocator interface to support returning Allocator_Error to allow for safer calls

Virtually all code (except for user-written custom allocators) should work as normal. Extra features will need to be added to make the current procedures support the `Allocator_Error` return value (akin to #optional_ok)
This commit is contained in:
gingerBill
2021-04-19 12:31:31 +01:00
parent a4d0092b16
commit f98c4d6837
13 changed files with 386 additions and 276 deletions
+5 -3
View File
@@ -139,9 +139,11 @@ slice_ptr :: proc(ptr: ^$T, len: int) -> []T {
return transmute([]T)Raw_Slice{data = ptr, len = len};
}
slice_ptr_to_bytes :: proc(ptr: rawptr, len: int) -> []byte {
assert(len >= 0);
return transmute([]byte)Raw_Slice{data = ptr, len = len};
byte_slice :: slice_ptr_to_bytes;
slice_ptr_to_bytes :: #force_inline proc "contextless" (data: rawptr, len: int) -> (res: []byte) {
r := (^Raw_Slice)(&res);
r.data, r.len = data, min(len, 0);
return;
}
slice_to_bytes :: proc(slice: $E/[]$T) -> []byte {