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.

memsetSmallPowerOf2

compiler_rt.memsetSmallPowerOf2
fn memsetSmallPowerOf2(d: [*]u8, b: u8, comptime size: usize) void

File

lib/compiler_rt.zig:652

Code

fn memsetSmallPowerOf2(d: [*]u8, b: u8, comptime size: usize) void {
    if (size > @sizeOf(usize)) {
        d[0..size].* = @splat(b);
    } else {
        const T = @Int(.unsigned, 8 * size);
        var splatted: T = 0; // Setting this to undefined causes a memset call and thus infinite recursion in Debug test-compiler-rt.
        @as(*[size]u8, @ptrCast(&splatted)).* = @splat(b);
        @as(*align(1) T, @ptrCast(d)).* = splatted;
    }
}