Create a new memory region with the given size.
(reserve_size: usize)
| 106 | impl ArenaMemoryProvider { |
| 107 | /// Create a new memory region with the given size. |
| 108 | pub fn new_with_size(reserve_size: usize) -> Result<Self, region::Error> { |
| 109 | let size = align_up(reserve_size, region::page::size()); |
| 110 | // Note: The region crate uses `MEM_RESERVE | MEM_COMMIT` on Windows. |
| 111 | // This means that allocations that exceed the page file plus system |
| 112 | // memory will fail here. |
| 113 | // https://github.com/darfink/region-rs/pull/34 |
| 114 | let mut alloc = region::alloc(size, region::Protection::NONE)?; |
| 115 | let ptr = alloc.as_mut_ptr(); |
| 116 | |
| 117 | Ok(Self { |
| 118 | alloc: ManuallyDrop::new(Some(alloc)), |
| 119 | segments: Vec::new(), |
| 120 | ptr, |
| 121 | size, |
| 122 | position: 0, |
| 123 | }) |
| 124 | } |
| 125 | |
| 126 | fn allocate_inner( |
| 127 | &mut self, |
nothing calls this directly
no test coverage detected