Function readSliceEndianAlloc [src]
The function is inline to avoid the dead code in case endian is
comptime-known and matches host endianness.
Prototype
pub inline fn readSliceEndianAlloc( r: *Reader, allocator: Allocator, comptime Elem: type, len: usize, endian: std.builtin.Endian, ) ReadAllocError![]Elem
Parameters
r: *Reader
allocator: Allocator
Elem: type
len: usize
endian: std.builtin.Endian
Possible Errors
Source
pub inline fn readSliceEndianAlloc(
r: *Reader,
allocator: Allocator,
comptime Elem: type,
len: usize,
endian: std.builtin.Endian,
) ReadAllocError![]Elem {
const dest = try allocator.alloc(Elem, len);
errdefer allocator.free(dest);
try readSliceAll(r, @ptrCast(dest));
if (native_endian != endian) for (dest) |*elem| std.mem.byteSwapAllFields(Elem, elem);
return dest;
}