Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Fixed

- Fix panic in `tlsf::Heap::used`.

## [v0.7.0] - 2026-01-03

### Added
Expand Down
4 changes: 4 additions & 0 deletions examples/tlsf_integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pub type TestTable<'a> = &'a [(fn() -> (), &'static str)];

fn test_global_heap() {
const ELEMS: usize = 250;
assert_eq!(HEAP_SIZE, HEAP.free() + HEAP.used());
let initial_free = HEAP.free();

let mut allocated = LinkedList::new();
for _ in 0..ELEMS {
Expand All @@ -51,6 +53,8 @@ fn test_global_heap() {
for i in 0..ELEMS {
assert_eq!(allocated.pop_front().unwrap(), i as i32);
}
assert_eq!(HEAP_SIZE, HEAP.free() + HEAP.used());
assert_eq!(initial_free, HEAP.free());
}

fn test_allocator_api() {
Expand Down
3 changes: 2 additions & 1 deletion src/tlsf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ impl Heap {
/// Get the amount of bytes used by the allocator.
pub fn used(&self) -> usize {
critical_section::with(|cs| {
self.heap.borrow_ref_mut(cs).raw_block_size - self.free_with_cs(cs)
let free = self.free_with_cs(cs);
self.heap.borrow_ref_mut(cs).raw_block_size - free
})
}

Expand Down