Skip to content

Commit

Permalink
Expose usable_size
Browse files Browse the repository at this point in the history
  • Loading branch information
nathaniel-daniel committed May 17, 2024
1 parent de45b6f commit 8f2a80c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ unsafe impl GlobalAlloc for MiMalloc {
}

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

#[test]
fn it_usable_size() {
fn it_checks_usable_size() {
unsafe {
let layout = Layout::from_size_align(8, 8).unwrap();
let alloc = MiMalloc;
Expand Down

0 comments on commit 8f2a80c

Please sign in to comment.