Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Public Function

munmap

Public Function
std.posix.munmap
pub fn munmap(memory: []align(page_size_min) const u8) void

Deletes the mappings for the specified address range, causing further references to addresses within the range to generate invalid memory references. Note that while POSIX allows unmapping a region in the middle of an existing mapping, Zig's munmap function does not, for two reasons:

  • It violates the Zig principle that resource deallocation must succeed.
  • The Windows function, NtFreeVirtualMemory, has this restriction.

Params

File

posix.zig:684
684
685
686
687
688
689
690
691
692
693
pub fn munmap(memory: []align(page_size_min) const u8) void {
    switch (errno(system.munmap(memory.ptr, memory.len))) {
        .SUCCESS => return,
        .INVAL => unreachable, // Invalid parameters.
        .NOMEM => unreachable, // Attempted to unmap a region in the middle of an existing mapping.
        else => |e| if (std.options.unexpected_error_tracing) {
            std.debug.panic("unexpected errno: {d} ({t})", .{ @backingInt(e), e });
        } else unreachable,
    }
}