Skip to main content

Crate pagealloc

Crate pagealloc 

Source
Expand description

Low-level, cross-platform page allocation library.

This crate provides a cross-platform interface to the operating system’s virtual memory allocation, such as mmap on Unix and VirtualAlloc on Windows.

§Crate features

  • std (default): Enables std compatibility.
  • buffer: Enables the buffer module, providing a safer API around allocation.

§Examples

unsafe {
    let ptr = pagealloc::alloc(
        std::ptr::null_mut(),
        pagealloc::alloc_granularity(),
        pagealloc::Protection::ReadWrite,
    )?;
    // ...
    pagealloc::dealloc(ptr, pagealloc::alloc_granularity())?;
}

Modules§

bufferbuffer
Higher-level safe wrapper for managing buffers.

Structs§

OsError
An error raised by the OS.

Enums§

Error
An error raised by the library.
Protection
The rights the user will have for a page.

Functions§

advise_free
Indicate to the system that a memory region will temporarily not be of interest. This way the system can use the memory if needed.
alloc
Allocate some virtual pages from the OS.
alloc_granularity
Returns the allocation granularity.
clear
Recommit a range of pages, such that they remain allocated and return zero when accessed.
dealloc
Deallocate previously allocated virtual pages, releasing them to the OS.
page_size
Returns the page size.
protect
Change the protection of a range of pages.

Type Aliases§

Result
Alias for Result<T, Error>.