diff --git a/Cargo.toml b/Cargo.toml index 4aee4be..899166d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "mimalloc" -version = "0.1.48" +version = "0.1.49" authors = [ "Octavian Oncescu ", "Vincent Rouillé ", "Thom Chiovoloni ", ] -edition = "2018" +edition = "2024" repository = "https://github.com/purpleprotocol/mimalloc_rust" keywords = ["mimalloc", "allocator", "encrypted-heap", "performance"] categories = ["memory-management", "api-bindings"] diff --git a/libmimalloc-sys/Cargo.toml b/libmimalloc-sys/Cargo.toml index 67eeb4c..e078b97 100644 --- a/libmimalloc-sys/Cargo.toml +++ b/libmimalloc-sys/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "libmimalloc-sys" -version = "0.1.44" +version = "0.1.45" authors = ["Octavian Oncescu "] -edition = "2018" +edition = "2024" repository = "https://github.com/purpleprotocol/mimalloc_rust/tree/master/libmimalloc-sys" keywords = ["allocator", "encrypted-heap", "performance"] categories = ["memory-management", "api-bindings"] @@ -29,7 +29,7 @@ cty = { version = "0.2", optional = true } libc = "0.2" [build-dependencies] -cc = "1.0" +cc = "1.2" [features] secure = [] diff --git a/libmimalloc-sys/c_src/mimalloc/v2 b/libmimalloc-sys/c_src/mimalloc/v2 index fbd8b99..6a53d72 160000 --- a/libmimalloc-sys/c_src/mimalloc/v2 +++ b/libmimalloc-sys/c_src/mimalloc/v2 @@ -1 +1 @@ -Subproject commit fbd8b99c2b828428947d70fdc046bb55609be93e +Subproject commit 6a53d72d46a1a641d8e5793db37cb2da60e04192 diff --git a/libmimalloc-sys/c_src/mimalloc/v3 b/libmimalloc-sys/c_src/mimalloc/v3 index dfa50c3..7b7fca4 160000 --- a/libmimalloc-sys/c_src/mimalloc/v3 +++ b/libmimalloc-sys/c_src/mimalloc/v3 @@ -1 +1 @@ -Subproject commit dfa50c37d951128b1e77167dd9291081aa88eea4 +Subproject commit 7b7fca4b7013d77e356d96e055fec309cb3cbbd6 diff --git a/libmimalloc-sys/src/lib.rs b/libmimalloc-sys/src/lib.rs index ff2442e..f371d98 100644 --- a/libmimalloc-sys/src/lib.rs +++ b/libmimalloc-sys/src/lib.rs @@ -10,7 +10,7 @@ mod extended; #[cfg(feature = "extended")] pub use extended::*; -extern "C" { +unsafe extern "C" { /// Allocate zero-initialized `size` bytes. /// /// Returns a pointer to newly allocated zero-initialized memory, or null if diff --git a/libmimalloc-sys/sys-test/build.rs b/libmimalloc-sys/sys-test/build.rs index 383f0dc..e4ef3a7 100644 --- a/libmimalloc-sys/sys-test/build.rs +++ b/libmimalloc-sys/sys-test/build.rs @@ -1,7 +1,8 @@ -use std::env; +use std::{env, fs, path::PathBuf}; fn main() { let cargo_manifest_dir = env!("CARGO_MANIFEST_DIR"); + let out_dir = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR is set by cargo")); let secure = if env::var("CARGO_FEATURE_SECURE").is_ok() { Some("secure") } else { @@ -55,5 +56,10 @@ fn main() { } }); - cfg.generate("../src/lib.rs", "all.rs"); + let source = fs::read_to_string("../src/lib.rs").expect("read libmimalloc-sys/src/lib.rs"); + let ctest_source = source.replace("unsafe extern \"C\"", "extern \"C\""); + let ctest_input = out_dir.join("ctest-input.rs"); + fs::write(&ctest_input, ctest_source).expect("write generated ctest input"); + + cfg.generate(ctest_input, "all.rs"); } diff --git a/libmimalloc-sys/sys-test/src/main.rs b/libmimalloc-sys/sys-test/src/main.rs index 385a34d..7ae7ca0 100644 --- a/libmimalloc-sys/sys-test/src/main.rs +++ b/libmimalloc-sys/sys-test/src/main.rs @@ -1,4 +1,10 @@ -#![allow(bad_style, unused_imports, unused_macros, clippy::all)] +#![allow( + bad_style, + unused_imports, + unused_macros, + function_casts_as_integer, + clippy::all +)] use libmimalloc_sys::*; diff --git a/src/lib.rs b/src/lib.rs index 4288b2f..c12c383 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,22 +48,24 @@ pub struct MiMalloc; unsafe impl GlobalAlloc for MiMalloc { #[inline] unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - mi_malloc_aligned(layout.size(), layout.align()) as *mut u8 + unsafe { mi_malloc_aligned(layout.size(), layout.align()) as *mut u8 } } #[inline] unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { - mi_zalloc_aligned(layout.size(), layout.align()) as *mut u8 + unsafe { mi_zalloc_aligned(layout.size(), layout.align()) as *mut u8 } } #[inline] unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) { - mi_free(ptr as *mut c_void); + unsafe { + mi_free(ptr as *mut c_void); + } } #[inline] unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { - mi_realloc_aligned(ptr as *mut c_void, new_size, layout.align()) as *mut u8 + unsafe { mi_realloc_aligned(ptr as *mut c_void, new_size, layout.align()) as *mut u8 } } } diff --git a/test-override-with-dylib/Cargo.toml b/test-override-with-dylib/Cargo.toml index c1381fc..4c174a9 100644 --- a/test-override-with-dylib/Cargo.toml +++ b/test-override-with-dylib/Cargo.toml @@ -7,11 +7,11 @@ edition = "2018" publish = false [dependencies] -libc = { version = "^0.2.8", default-features = false } +libc = { version = "^0.2.182", default-features = false } libmimalloc-sys = { path = "../libmimalloc-sys" } [build-dependencies] -cc = "^1.0.13" +cc = "^1.2.56" [features] override = ["libmimalloc-sys/override"]