(&self, layout: Layout)
| 19 | |
| 20 | unsafe impl GlobalAlloc for LeanAlloc { |
| 21 | unsafe fn alloc(&self, layout: Layout) -> *mut u8 { |
| 22 | let alignment = layout.align().max(LEAN_OBJECT_SIZE_DELTA); |
| 23 | let offset = layout.size().wrapping_neg() & (alignment - 1); |
| 24 | let size = layout.size() + offset; |
| 25 | |
| 26 | #[cfg(feature = "small_allocator")] |
| 27 | if alignment == LEAN_OBJECT_SIZE_DELTA && size <= crate::LEAN_MAX_SMALL_OBJECT_SIZE as usize |
| 28 | { |
| 29 | let slot_idx = crate::lean_get_slot_idx(size as _); |
| 30 | return crate::lean_alloc_small(size as _, slot_idx).cast(); |
| 31 | } |
| 32 | |
| 33 | lean_inc_heartbeat(); |
| 34 | aligned_alloc(alignment, size) |
| 35 | } |
| 36 | |
| 37 | #[allow(unused_variables)] |
| 38 | unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { |
nothing calls this directly
no test coverage detected