Skip to content

Expose version function #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2024
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
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ jobs:

- name: Test libmimalloc-sys crate bindings (no secure)
run: cargo run -p libmimalloc-sys-test

- name: Build (extended)
run: cargo build --features extended

- name: Test (extended)
run: cargo test --features extended

- name: Test libmimalloc-sys crate bindings (extended)
run: cargo run --features extended -p libmimalloc-sys-test

lint:
name: Rustfmt / Clippy
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ debug = ["libmimalloc-sys/debug"]
debug_in_debug = ["libmimalloc-sys/debug_in_debug"]
local_dynamic_tls = ["libmimalloc-sys/local_dynamic_tls"]
no_thp = ["libmimalloc-sys/no_thp"]
extended = ["libmimalloc-sys/extended"]
21 changes: 21 additions & 0 deletions src/extended.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use crate::MiMalloc;

impl MiMalloc {
/// Get the mimalloc version.
///
/// For mimalloc version 1.8.6, this will return 186.
pub fn version(&self) -> u32 {
unsafe { ffi::mi_version() as u32 }
}
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn it_gets_version() {
let version = MiMalloc.version();
assert!(version != 0);
}
}
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

extern crate libmimalloc_sys as ffi;

#[cfg(feature = "extended")]
mod extended;

use core::alloc::{GlobalAlloc, Layout};
use core::ffi::c_void;
use ffi::*;
Expand Down