Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › compress/ › xz/ › Decompress.zig › finish
finish
Decompress.finish
fn finish (d : *Decompress ) !void
File
Code
fn finish (d : *Decompress ) !void {
const input = d .input ;
const index_size = blk : {
assert (input .buffered ()[0 ] == 0 );
var input_counter : u64 = 1 ;
var checksum : Crc32 = .init ();
checksum .update (&.{0 });
input .toss (1 );
const record_count = try countLeb128 (input , u64 , &input_counter , &checksum );
if (record_count != d .block_count )
return error .CorruptInput ;
for (0 ..@intCast (record_count )) |_ | {
_ = try countLeb128 (input , u64 , &input_counter , &checksum );
_ = try countLeb128 (input , u64 , &input_counter , &checksum );
}
const padding = try input .take (@intCast ((4 - (input_counter % 4 )) % 4 ));
for (padding ) |byte | {
if (byte != 0 ) return error .CorruptInput ;
}
checksum .update (padding );
const declared_checksum = try input .takeInt (u32 , .little );
const computed_checksum = checksum .final ();
if (computed_checksum != declared_checksum ) return error .WrongChecksum ;
break :blk input_counter + padding .len + 4 ;
};
const declared_checksum = try input .takeInt (u32 , .little );
const computed_checksum = Crc32 .hash (try input .peek (4 + @sizeOf (StreamFlags )));
if (declared_checksum != computed_checksum ) return error .WrongChecksum ;
const backward_size = (@as (u64 , try input .takeInt (u32 , .little )) + 1 ) * 4 ;
if (backward_size != index_size ) return error .CorruptInput ;
input .toss (@sizeOf (StreamFlags ));
if (!std .mem .eql (u8 , try input .takeArray (2 ), &.{ 'Y' , 'Z' }))
return error .CorruptInput ;
}