Skip to content

Commit e69ba9b

Browse files
committed
Fix panic when calling tlsf::Heap::used()
1 parent 281054d commit e69ba9b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/tlsf.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ impl Heap {
101101
/// Get the amount of bytes used by the allocator.
102102
pub fn used(&self) -> usize {
103103
critical_section::with(|cs| {
104-
self.heap.borrow_ref_mut(cs).raw_block_size - self.free_with_cs(cs)
104+
let free = self.free_with_cs(cs);
105+
self.heap.borrow_ref_mut(cs).raw_block_size - free
105106
})
106107
}
107108

0 commit comments

Comments
 (0)