pub unsafe fn release(
reservation: *mut u8,
reservation_len: usize,
align: usize,
)Expand description
Release a whole OS reservation obtained from Reservation::into_parts.
§Safety
reservation, reservation_len and align must be the three values
returned by Reservation::into_parts (or, for a self-hosting caller that
always uses one alignment, that same alignment constant), and the
reservation must be released exactly once. The native (munmap /
VirtualFree) paths ignore align; it is consulted only by the miri
fallback to reconstruct the exact Layout.
If reservation is null, this function returns early and does nothing
(the call is a no-op). The mock recorder is also skipped in this case,
so a mock-based test’s expected call log may desync if it expects a
record for a null pointer.
§Panics
Panics if reservation is non-null and (reservation_len, align) violates
the documented contract above: reservation_len must be non-zero and a
multiple of PAGE, align must be a power of two >= PAGE, and the
pair must form a valid std::alloc::Layout. The assert runs before
mock::record, so under the aligned_vmem_mock cfg a contract-violating
call panics before it is ever recorded in the mock call log — it does not
appear as a Release entry.
A null reservation is unaffected by this: it remains the documented
no-op above and is not a panic path.