Remove the need for this to be mut and write it in a more 'rusty' way

This commit is contained in:
Gwilym Kuiper 2021-08-16 21:08:39 +01:00
parent 22c6efa5fa
commit cd4718f8c5

View file

@ -28,11 +28,11 @@ impl BumpAllocator {
fn alloc_safe(&self, layout: Layout) -> *mut u8 { fn alloc_safe(&self, layout: Layout) -> *mut u8 {
let mut current_ptr = self.current_ptr.lock(); let mut current_ptr = self.current_ptr.lock();
let mut ptr = *current_ptr as usize; let ptr = if current_ptr.is_null() {
get_data_end()
if ptr == 0 { } else {
ptr = get_data_end(); *current_ptr as usize
} };
let alignment_bitmask = layout.align() - 1; let alignment_bitmask = layout.align() - 1;
let fixup = ptr & alignment_bitmask; let fixup = ptr & alignment_bitmask;