From d17373330d6b05b7e61bfef84824948a2db70190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Tue, 10 Oct 2023 21:31:11 +0200 Subject: [PATCH] Replace manual borrow_mut --- esp-wifi/src/compat/malloc.rs | 8 +++----- esp-wifi/src/lib.rs | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/esp-wifi/src/compat/malloc.rs b/esp-wifi/src/compat/malloc.rs index 27dcce16..8da87f35 100644 --- a/esp-wifi/src/compat/malloc.rs +++ b/esp-wifi/src/compat/malloc.rs @@ -9,8 +9,7 @@ pub unsafe extern "C" fn malloc(size: usize) -> *const u8 { let layout = Layout::from_size_align_unchecked(total_size, 4); let ptr = critical_section::with(|cs| { - HEAP.borrow(cs) - .borrow_mut() + HEAP.borrow_ref_mut(cs) .allocate_first_fit(layout) .ok() .map_or(core::ptr::null_mut(), |allocation| allocation.as_ptr()) @@ -21,7 +20,7 @@ pub unsafe extern "C" fn malloc(size: usize) -> *const u8 { return ptr; } - *(ptr as *mut _ as *mut usize) = total_size; + *(ptr as *mut usize) = total_size; ptr.offset(4) } @@ -37,8 +36,7 @@ pub unsafe extern "C" fn free(ptr: *const u8) { let layout = Layout::from_size_align_unchecked(total_size, 4); critical_section::with(|cs| { - HEAP.borrow(cs) - .borrow_mut() + HEAP.borrow_ref_mut(cs) .deallocate(core::ptr::NonNull::new_unchecked(ptr as *mut u8), layout) }); } diff --git a/esp-wifi/src/lib.rs b/esp-wifi/src/lib.rs index 8e619ebb..d57c199b 100644 --- a/esp-wifi/src/lib.rs +++ b/esp-wifi/src/lib.rs @@ -162,8 +162,7 @@ pub(crate) static HEAP: Mutex> = Mutex::new(RefCell::new(Heap::emp fn init_heap() { critical_section::with(|cs| { - HEAP.borrow(cs) - .borrow_mut() + HEAP.borrow_ref_mut(cs) .init_from_slice(unsafe { &mut HEAP_DATA }) }); }