Skip to content

Commit

Permalink
Merge pull request #122 from michel-slm/fix-usable-size-gating
Browse files Browse the repository at this point in the history
Fix mi_usable_size gating
  • Loading branch information
octavonce authored Jun 2, 2024
2 parents a9c410c + 4b809e2 commit 859fbc1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 10 additions & 0 deletions libmimalloc-sys/src/extended.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,16 @@ extern "C" {
mod tests {
use super::*;

#[test]
fn it_calculates_usable_size() {
let ptr = unsafe { mi_malloc(32) } as *mut u8;
let usable_size = unsafe { mi_usable_size(ptr as *mut c_void) };
assert!(
usable_size >= 32,
"usable_size should at least equal to the allocated size"
);
}

#[test]
fn runtime_stable_option() {
unsafe {
Expand Down
10 changes: 0 additions & 10 deletions libmimalloc-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,4 @@ mod tests {
let ptr = unsafe { mi_realloc_aligned(ptr as *mut c_void, 8, 8) } as *mut u8;
unsafe { mi_free(ptr as *mut c_void) };
}

#[test]
fn it_calculates_usable_size() {
let ptr = unsafe { mi_malloc(32) } as *mut u8;
let usable_size = unsafe { mi_usable_size(ptr as *mut c_void) };
assert!(
usable_size >= 32,
"usable_size should at least equal to the allocated size"
);
}
}

0 comments on commit 859fbc1

Please sign in to comment.