(&self, layout: Layout)
| 141 | unsafe impl GlobalAlloc for Locked<LnLsAlloc> |
| 142 | { |
| 143 | unsafe fn alloc(&self, layout: Layout) -> *mut u8 |
| 144 | { |
| 145 | // Make adjustment(s) to layout: |
| 146 | let (size, align) = LnLsAlloc::sizealign(layout); |
| 147 | let mut allocator = self.lock(); |
| 148 | |
| 149 | if let Some((region, alloc_start)) = allocator.findrgn(size, align) |
| 150 | { |
| 151 | let alloc_end = alloc_start.checked_add(size).expect("[ERR] OVERFLOW"); |
| 152 | let excess_size = region.addr_end() - alloc_end; |
| 153 | if excess_size > 0 |
| 154 | { |
| 155 | allocator.add_freergn(alloc_end, excess_size); |
| 156 | } |
| 157 | alloc_start as *mut u8 |
| 158 | } |
| 159 | else |
| 160 | { |
| 161 | ptr::null_mut() |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) |
| 166 | { |
nothing calls this directly
no test coverage detected