| ... | ... | @@ -377,9 +377,9 @@ pub fn readType(reader: anytype, comptime T: type, endian: std.builtin.Endian) ! |
| 377 | 377 | }; |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | | pub fn indexBufferT(bytes: []const u8, comptime T: type, endian: std.builtin.Endian, idx: usize, max_len: usize) T { |
| 380 | pub fn indexBufferT(bytes: [*]const u8, comptime T: type, endian: std.builtin.Endian, idx: usize, max_len: usize) T { |
| 381 | 381 | std.debug.assert(idx < max_len); |
| 382 | | var fbs = std.io.fixedBufferStream(bytes[idx * @sizeOf(T) ..]); |
| 382 | var fbs = std.io.fixedBufferStream((bytes + (idx * @sizeOf(T)))[0..@sizeOf(T)]); |
| 383 | 383 | return readType(fbs.reader(), T, endian) catch |err| switch (err) { |
| 384 | 384 | error.EndOfStream => unreachable, // assert above has been violated |
| 385 | 385 | }; |
| ... | ... | @@ -393,7 +393,6 @@ pub fn BufIndexer(comptime T: type, comptime endian: std.builtin.Endian) type { |
| 393 | 393 | const Self = @This(); |
| 394 | 394 | |
| 395 | 395 | pub fn init(bytes: []const u8, max_len: usize) Self { |
| 396 | | std.debug.assert(bytes.len >= @sizeOf(T) * max_len); |
| 397 | 396 | return .{ |
| 398 | 397 | .bytes = bytes.ptr, |
| 399 | 398 | .max_len = max_len, |
| ... | ... | @@ -401,7 +400,7 @@ pub fn BufIndexer(comptime T: type, comptime endian: std.builtin.Endian) type { |
| 401 | 400 | } |
| 402 | 401 | |
| 403 | 402 | pub fn at(self: *const Self, idx: usize) T { |
| 404 | | return indexBufferT(self.bytes[0 .. @sizeOf(T) * self.max_len], T, endian, idx, self.max_len); |
| 403 | return indexBufferT(self.bytes, T, endian, idx, self.max_len); |
| 405 | 404 | } |
| 406 | 405 | }; |
| 407 | 406 | } |