Skip to content

Commit de6cf88

Browse files
committed
Expose stats
1 parent 1b66180 commit de6cf88

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ documentation = "https://docs.rs/buddy_system_allocator"
55
homepage = "https://github.com/rcore-os/buddy_system_allocator"
66
repository = "https://github.com/rcore-os/buddy_system_allocator"
77
keywords = ["allocator", "no_std", "heap"]
8-
version = "0.3.9"
8+
version = "0.4.0"
99
authors = ["Jiajie Chen <noc@jiegec.ac.cn>"]
1010
edition = "2018"
1111
license = "MIT"

src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,21 @@ impl Heap {
190190
self.user -= layout.size();
191191
self.allocated -= size;
192192
}
193+
194+
/// Return the number of bytes that user requests
195+
pub fn stats_alloc_user(&self) -> usize {
196+
self.user
197+
}
198+
199+
/// Return the number of bytes that are actually allocated
200+
pub fn stats_alloc_actual(&self) -> usize {
201+
self.allocated
202+
}
203+
204+
/// Return the total number of bytes in the heap
205+
pub fn stats_total_bytes(&self) -> usize {
206+
self.total
207+
}
193208
}
194209

195210
impl fmt::Debug for Heap {

0 commit comments

Comments
 (0)