Create a new `PtrLen` pointing to at least `size` bytes of memory, suitably sized and aligned for memory protection.
(size: usize)
| 27 | /// Create a new `PtrLen` pointing to at least `size` bytes of memory, |
| 28 | /// suitably sized and aligned for memory protection. |
| 29 | fn with_size(size: usize) -> io::Result<Self> { |
| 30 | let alloc_size = region::page::ceil(size as *const ()) as usize; |
| 31 | MmapMut::map_anon(alloc_size).map(|mut mmap| { |
| 32 | // The order here is important; we assign the pointer first to get |
| 33 | // around compile time borrow errors. |
| 34 | Self { |
| 35 | ptr: mmap.as_mut_ptr(), |
| 36 | map: Some(mmap), |
| 37 | len: alloc_size, |
| 38 | } |
| 39 | }) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | /// JIT memory manager. This manages pages of suitably aligned and |
nothing calls this directly
no test coverage detected