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.

readObjectRaw

Reads the complete contents of an object from reader. This function may read more bytes than required from reader, so the reader position after returning is not reliable.

git.readObjectRaw
fn readObjectRaw(allocator: Allocator, reader: *Io.Reader, size: u64) ![]u8

File

Code

fn readObjectRaw(allocator: Allocator, reader: *Io.Reader, size: u64) ![]u8 {
    const alloc_size = std.math.cast(usize, size) orelse return error.ObjectTooLarge;
    var aw: Io.Writer.Allocating = .init(allocator);
    try aw.ensureTotalCapacity(alloc_size + std.compress.flate.max_window_len);
    defer aw.deinit();
    var decompress: std.compress.flate.Decompress = .init(reader, .zlib, &.{});
    try decompress.reader.streamExact(&aw.writer, alloc_size);
    return aw.toOwnedSlice();
}