Function init [src]

XZ uses a series of LZMA2 blocks which each specify a dictionary size anywhere from 4K to 4G. Thus, this API dynamically allocates the dictionary as-needed.

Prototype

pub fn init( input: *Reader, gpa: Allocator, buffer: []u8, ) !Decompress

Parameters

input: *Readergpa: Allocatorbuffer: []u8Decompress takes ownership of this buffer and resizes it with gpa.

Source

pub fn init( input: *Reader, gpa: Allocator, /// Decompress takes ownership of this buffer and resizes it with `gpa`. buffer: []u8, ) !Decompress { const magic = try input.takeArray(6); if (!std.mem.eql(u8, magic, &.{ 0xFD, '7', 'z', 'X', 'Z', 0x00 })) return error.NotXzStream; const computed_checksum = Crc32.hash(try input.peek(@sizeOf(StreamFlags))); const stream_flags = input.takeStruct(StreamFlags, .little) catch unreachable; const stored_hash = try input.takeInt(u32, .little); if (computed_checksum != stored_hash) return error.WrongChecksum; return .{ .input = input, .reader = .{ .vtable = &.{ .stream = stream, .readVec = readVec, .discard = discard, }, .buffer = buffer, .seek = 0, .end = 0, }, .gpa = gpa, .check = stream_flags.check, .block_count = 0, .err = null, }; }