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): Enablesstdcompatibility.buffer: Enables thebuffermodule, 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§
- buffer
buffer - 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>.