Skip to content

Commit 9e39e9f

Browse files
committed
Improve heep
1 parent 1472ffe commit 9e39e9f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/common/simplest_heap.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,25 @@ impl Heap {
5151
once_flag.set(true);
5252

5353
self.heap
54-
.borrow(cs)
55-
.borrow_mut()
54+
.borrow_ref_mut(cs)
5655
.init(start_addr as *mut u8, size);
5756
});
5857
}
5958

6059
/// Returns an estimate of the amount of bytes in use.
6160
pub fn used(&self) -> usize {
62-
critical_section::with(|cs| self.heap.borrow(cs).borrow().used())
61+
critical_section::with(|cs| self.heap.borrow_ref(cs).used())
6362
}
6463

6564
/// Returns an estimate of the amount of bytes available.
6665
pub fn free(&self) -> usize {
67-
critical_section::with(|cs| self.heap.borrow(cs).borrow().free())
66+
critical_section::with(|cs| self.heap.borrow_ref(cs).free())
6867
}
6968
}
7069

7170
unsafe impl GlobalAlloc for Heap {
7271
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
73-
critical_section::with(|cs| self.heap.borrow(cs).borrow_mut().alloc(layout))
72+
critical_section::with(|cs| self.heap.borrow_ref_mut(cs).alloc(layout))
7473
}
7574

7675
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}

0 commit comments

Comments
 (0)