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: *Readerallocator: AllocatorElem: typelen: usizeendian: std.builtin.Endian

Possible Errors

EndOfStream Error
OutOfMemory Error
ReadFailed Error

See the Reader implementation for detailed diagnostics.

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; }