Skip to content

Commit 8f2a80c

Browse files
Expose usable_size
1 parent de45b6f commit 8f2a80c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,12 @@ unsafe impl GlobalAlloc for MiMalloc {
6363
}
6464

6565
impl MiMalloc {
66-
#[allow(dead_code)]
66+
/// Return the amount of available bytes in a memory block.
67+
///
68+
/// # Safety
69+
/// `ptr` must point to a memory block allocated by mimalloc, or be null.
6770
#[inline]
68-
unsafe fn usable_size(&self, ptr: *const u8) -> usize {
71+
pub unsafe fn usable_size(&self, ptr: *const u8) -> usize {
6972
mi_usable_size(ptr as *const c_void)
7073
}
7174
}
@@ -143,7 +146,7 @@ mod tests {
143146
}
144147

145148
#[test]
146-
fn it_usable_size() {
149+
fn it_checks_usable_size() {
147150
unsafe {
148151
let layout = Layout::from_size_align(8, 8).unwrap();
149152
let alloc = MiMalloc;

0 commit comments

Comments
 (0)