File tree Expand file tree Collapse file tree 3 files changed +38
-3
lines changed Expand file tree Collapse file tree 3 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
8
8
## [ Unreleased]
9
9
10
+ - Updated ` linked_list_allocator ` dependency to 0.10.5, which allows
11
+ compiling with stable rust.
12
+
10
13
## [ v0.5.0] - 2022-12-06
11
14
12
15
### Changed
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ critical-section = "1.0"
28
28
29
29
[dependencies .linked_list_allocator ]
30
30
default-features = false
31
- version = " 0.10.4 "
31
+ version = " 0.10.5 "
32
32
features = [" const_mut_refs" ]
33
33
34
34
[dev-dependencies ]
Original file line number Diff line number Diff line change 1
1
[ ![ crates.io] ( https://img.shields.io/crates/d/embedded-alloc.svg )] ( https://crates.io/crates/embedded-alloc )
2
2
[ ![ crates.io] ( https://img.shields.io/crates/v/embedded-alloc.svg )] ( https://crates.io/crates/embedded-alloc )
3
+ ![ Minimum Supported Rust Version] ( https://img.shields.io/badge/rustc-1.68+-blue.svg )
3
4
4
5
# ` embedded-alloc `
5
6
6
7
> A heap allocator for embedded systems.
7
8
8
- Note that using this as your global allocator requires nightly Rust.
9
+ Note that using this as your global allocator requires Rust 1.68 or later.
10
+ (With earlier versions, you need the unstable feature ` #![feature(default_alloc_error_handler)] ` )
9
11
10
12
This project is developed and maintained by the [ Cortex-M team] [ team ] .
11
13
12
14
## Example
13
15
14
- For a usage example, see ` examples/global_alloc.rs ` .
16
+ Starting with Rust 1.68, this crate can be used as a global allocator on stable Rust:
17
+
18
+ ``` rust
19
+ #![no_std]
20
+ #![no_main]
21
+
22
+ extern crate alloc;
23
+
24
+ use cortex_m_rt :: entry;
25
+ use embedded_alloc :: Heap ;
26
+
27
+ #[global_allocator]
28
+ static HEAP : Heap = Heap :: empty ();
29
+
30
+ #[entry]
31
+ fn main () -> ! {
32
+ // Initialize the allocator BEFORE you use it
33
+ {
34
+ use core :: mem :: MaybeUninit ;
35
+ const HEAP_SIZE : usize = 1024 ;
36
+ static mut HEAP_MEM : [MaybeUninit <u8 >; HEAP_SIZE ] = [MaybeUninit :: uninit (); HEAP_SIZE ];
37
+ unsafe { HEAP . init (HEAP_MEM . as_ptr () as usize , HEAP_SIZE ) }
38
+ }
39
+
40
+ // now the allocator is ready types like Box, Vec can be used.
41
+
42
+ loop { /* .. */ }
43
+ }
44
+ ```
45
+
46
+ For a full usage example, see ` examples/global_alloc.rs ` .
15
47
16
48
## [ Documentation] ( https://docs.rs/embedded-alloc )
17
49
You can’t perform that action at this time.
0 commit comments