Skip to content

Commit

Permalink
perf(alloc): forward realloc
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Kröning <[email protected]>
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
SFBdragon and mkroening committed Apr 19, 2024
1 parent 0d71c45 commit dd9d69a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/mm/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ unsafe impl GlobalAlloc for LockedAllocator {
let layout = Self::align_layout(layout);
unsafe { self.0.alloc_zeroed(layout) }
}

unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
let layout = Self::align_layout(layout);
let new_size = new_size.align_up(core::mem::size_of::<crossbeam_utils::CachePadded<u8>>());
unsafe { self.0.realloc(ptr, layout, new_size) }
}
}

#[cfg(all(test, not(target_os = "none")))]
Expand Down

0 comments on commit dd9d69a

Please sign in to comment.