You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/lib.rs
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -4,22 +4,22 @@
4
4
//! - Memory that is freed by the same thread that allocated it does not require any synchronising operations.
5
5
//! - Freeing memory in a different thread to initially allocated it, does not take any locks and instead uses a novel message passing scheme to return the memory to the original allocator, where it is recycled.
6
6
//! - The allocator uses large ranges of pages to reduce the amount of meta-data required.
7
-
//!
7
+
//!
8
8
//! The benchmark is available at the [paper](https://github.com/microsoft/snmalloc/blob/master/snmalloc.pdf) of `snmalloc`
9
9
//! There are three features defined in this crate:
10
10
//! - `debug`: Enable the `Debug` mode in `snmalloc`.
11
11
//! - `1mib`: Use the `1mib` chunk configuration.
12
12
//! - `cache-friendly`: Make the allocator more cache friendly (setting `CACHE_FRIENDLY_OFFSET` to `64` in building the library).
13
-
//!
13
+
//!
14
14
//! The whole library supports `no_std`.
15
-
//!
15
+
//!
16
16
//! To use `snmalloc-rs` add it as a dependency:
17
17
//! ```toml
18
18
//! # Cargo.toml
19
19
//! [dependencies]
20
20
//! snmalloc-rs = "0.1.0"
21
21
//! ```
22
-
//!
22
+
//!
23
23
//! To set `SnMalloc` as the global allocator add this to your project:
24
24
//! ```rust
25
25
//! #[global_allocator]
@@ -32,8 +32,8 @@ use core::alloc::{GlobalAlloc, Layout};
32
32
pubstructSnMalloc;
33
33
34
34
unsafeimplGlobalAllocforSnMalloc{
35
-
/// Allocate the memory with the given alignment and size.
36
-
/// On success, it returns a pointer pointing to the required memory address.
35
+
/// Allocate the memory with the given alignment and size.
36
+
/// On success, it returns a pointer pointing to the required memory address.
37
37
/// On failure, it returns a null pointer.
38
38
/// The client must assure the following things:
39
39
/// - `alignment` is greater than zero
@@ -44,7 +44,7 @@ unsafe impl GlobalAlloc for SnMalloc {
44
44
ffi::rust_alloc(layout.align(), layout.size())as_
45
45
}
46
46
47
-
/// De-allocate the memory at the given address with the given alignment and size.
47
+
/// De-allocate the memory at the given address with the given alignment and size.
48
48
/// The client must assure the following things:
49
49
/// - the memory is acquired using the same allocator and the pointer points to the start position.
50
50
/// - Other constrains are the same as the rust standard library.
@@ -54,8 +54,8 @@ unsafe impl GlobalAlloc for SnMalloc {
0 commit comments