Skip to content

Commit

Permalink
Merge pull request #119 from nathaniel-daniel/version
Browse files Browse the repository at this point in the history
  • Loading branch information
octavonce authored May 19, 2024
2 parents de45b6f + 7a15df1 commit 4ae150e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
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

0 comments on commit 4ae150e

Please sign in to comment.