authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-02-11 13:50:25 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-02-11 13:51:03 -08:00
logb303caba8d260bb4d1a3fc7a29d983a6a56bb8ce
tree8091b82e72652d2f2c276db46970df8819fce50f
parent41656e532f2229c6dcd4b512f2a170983988c299

add skipToBoundary()


1 files changed, 8 insertions(+), 0 deletions(-)

src/lib.zig+8
...@@ -404,3 +404,11 @@ pub fn BufIndexer(comptime T: type, comptime endian: std.builtin.Endian) type {...@@ -404,3 +404,11 @@ pub fn BufIndexer(comptime T: type, comptime endian: std.builtin.Endian) type {
404 }404 }
405 };405 };
406}406}
407
408pub fn skipToBoundary(pos: u64, boundary: u64, reader: anytype) !void {
409 // const gdiff = counter.bytes_read % 4;
410 // for (range(if (gdiff > 0) 4 - gdiff else 0)) |_| {
411 const a = pos;
412 const b = boundary;
413 try reader.skipBytes(((a + (b - 1)) & ~(b - 1)) - a, .{});
414}