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.

smallMemset

compiler_rt.smallMemset
fn smallMemset(dest: ?[*]u8, c: c_int, len: usize) callconv(.c) ?[*]u8

File

lib/compiler_rt.zig:718

Code

fn smallMemset(dest: ?[*]u8, c: c_int, len: usize) callconv(.c) ?[*]u8 {
    const b: u8 = @truncate(@as(c_uint, @bitCast(c)));

    if (len != 0) {
        var d = dest.?;
        var n = len;
        while (true) {
            d[0] = b;
            n -= 1;
            if (n == 0) break;
            d += 1;
        }
    }

    return dest;
}