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.

alignPointer

Aligns a given pointer value to a specified alignment factor. Returns an aligned pointer or null if one of the following conditions is met:

mem.alignPointer
pub fn alignPointer(ptr: anytype, align_to: usize) ?@TypeOf(ptr)

File

lib/std/mem.zig:4300

Code

pub fn alignPointer(ptr: anytype, align_to: usize) ?@TypeOf(ptr) {
    const adjust_off = alignPointerOffset(ptr, align_to) orelse return null;
    // Avoid the use of ptrFromInt to avoid losing the pointer provenance info.
    return @alignCast(ptr + adjust_off);
}