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.

readSparseBitVector

Pdb.readSparseBitVector
fn readSparseBitVector(reader: *Io.Reader, gpa: Allocator) ![]u32

File

lib/std/debug/Pdb.zig:1136

Code

fn readSparseBitVector(reader: *Io.Reader, gpa: Allocator) ![]u32 {
    const num_words = try reader.takeInt(u32, .little);
    var list: std.ArrayList(u32) = .empty;
    defer list.deinit(gpa);
    var word_i: u32 = 0;
    while (word_i != num_words) : (word_i += 1) {
        const word = try reader.takeInt(u32, .little);
        var bit_i: u5 = 0;
        while (true) : (bit_i += 1) {
            if (word & (@as(u32, 1) << bit_i) != 0) {
                try list.append(gpa, word_i * 32 + bit_i);
            }
            if (bit_i == std.math.maxInt(u5)) break;
        }
    }
    return try list.toOwnedSlice(gpa);
}