pub fn alloc_at<T>(
address: *const T,
size: usize,
protection: Protection
) -> Result<Allocation>
Expand description
Allocates one or more pages of memory, at a specific address, with a defined protection.
The returned memory allocation is not guaranteed to reside at the provided address. E.g. on Windows, new allocations that do not reside within already reserved memory, are aligned to the operating system’s allocation granularity (most commonly 64KB).
§Implementation
This function is implemented using VirtualAlloc
on Windows, and mmap
with MAP_FIXED
on POSIX.
§Parameters
- The address is rounded down to the closest page boundary.
- The size may not be zero.
- The size is rounded up to the closest page boundary, relative to the address.
§Errors
- If an interaction with the underlying operating system fails, an error will be returned.
- If size is zero,
Error::InvalidParameter
will be returned.