Skip to content

Commit cfb9deb

Browse files
committed
Merged new mimalloc version from upstream
1 parent 53a232d commit cfb9deb

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ libmimalloc-sys = { path = "libmimalloc-sys", version = "0.1.7" }
2525

2626
[features]
2727
default = ["secure"]
28-
secure = ["libmimalloc-sys/secure"]
28+
secure = ["libmimalloc-sys/secure"]
29+
secure-full = ["libmimalloc-sys/secure", "libmimalloc-sys/secure-full"]

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,21 @@ randomized allocation, encrypted free lists, etc. The performance penalty should
2626
only be around 3% according to [mimalloc](https://github.com/microsoft/mimalloc)
2727
own benchmarks.
2828

29-
To disable secure mode, in `Cargo.toml`:
29+
To disable secure mode, put in `Cargo.toml`:
3030
```rust
3131
[dependencies]
3232
mimalloc = { version = "*", default-features = false }
3333
```
3434

35+
## Usage with full secure mode
36+
From version 1.2.0, mimalloc exposes another layer of secure features named `full-secure mode` that adds double-free mitigation. However, this might result in a bigger runtime performance hit than using only the plain secure mode.
37+
38+
To run mimalloc in full-secure mode, put in `Cargo.toml`:
39+
```rust
40+
[dependencies]
41+
mimalloc = { version = "*", features = "secure-full" }
42+
```
43+
3544
[crates.io]: https://crates.io/crates/mimalloc
3645
[Latest Version]: https://img.shields.io/crates/v/mimalloc.svg
3746
[Documentation]: https://docs.rs/mimalloc/badge.svg

libmimalloc-sys/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ libc = "0.2"
1616
cmake = "0.1"
1717

1818
[features]
19-
secure = []
19+
secure = []
20+
secure-full = []

libmimalloc-sys/build.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ fn main() {
55

66
cfg = cfg.define("MI_OVERRIDE", "OFF");
77
cfg = cfg.define("MI_SECURE", "OFF");
8+
cfg = cfg.define("MI_SECURE_FULL", "OFF");
9+
cfg = cfg.define("MI_BUILD_TESTS", "OFF");
810

911
if cfg!(feature = "secure") {
1012
cfg = cfg.define("MI_SECURE", "ON");
1113
}
1214

15+
if cfg!(feature = "secure-full") {
16+
cfg = cfg.define("MI_SECURE_FULL", "ON");
17+
}
18+
1319
// Inject MI_DEBUG=0
1420
// This set mi_option_verbose and mi_option_show_errors options to false.
1521
cfg = cfg.define("mi_defines", "MI_DEBUG=0");
@@ -29,7 +35,11 @@ fn main() {
2935

3036
let (out_dir, out_name) = if cfg!(all(windows, target_env = "msvc")) {
3137
if cfg!(debug_assertions) {
32-
("./build/Debug", "mimalloc-static-debug")
38+
if cfg!(feature = "secure") {
39+
("./build/Debug", "mimalloc-static-secure-debug")
40+
} else {
41+
("./build/Debug", "mimalloc-static-debug")
42+
}
3343
} else {
3444
if cfg!(feature = "secure") {
3545
("./build/Release", "mimalloc-static-secure")
@@ -39,7 +49,11 @@ fn main() {
3949
}
4050
} else {
4151
if cfg!(debug_assertions) {
42-
("./build", "mimalloc-debug")
52+
if cfg!(feature = "secure") {
53+
("./build", "mimalloc-secure-debug")
54+
} else {
55+
("./build", "mimalloc-debug")
56+
}
4357
} else {
4458
if cfg!(feature = "secure") {
4559
("./build", "mimalloc-secure")

0 commit comments

Comments
 (0)