10 releases
0.4.0 | Aug 3, 2023 |
---|---|
0.3.4 | May 26, 2023 |
0.3.3 | Jan 28, 2021 |
0.2.1 | Jan 27, 2021 |
0.1.1 | Jan 27, 2021 |
#312 in Memory management
10,755 downloads per month
Used in 5 crates
(3 directly)
7KB
107 lines
alloca-rs
Mostly safe no_std wrapper for alloca
in Rust.
This crate uses Rust lifetime system to ensure that stack allocated memory will not be used after function return, but it does not make any guarantee about memory that is turned into raw pointer and stored somewhere else.
Example
fn main() {
// allocate 128 bytes on the stack
alloca::with_alloca(128, |memory| {
// memory: &mut [MaybeUninit<u8>]
assert_eq!(memory.len(), 128);
});
}
lib.rs
:
Mostly safe no_std wrapper for alloca
in Rust.
This crate uses Rust lifetime system to ensure that stack allocated memory will not be used after function return, but it does not make any guarantee about memory that is turned into raw pointer and stored somewhere else.
Example
// allocate 128 bytes on the stack
alloca::with_alloca(128, |memory| {
// memory: &mut [MaybeUninit<u8>]
assert_eq!(memory.len(), 128);
});
No runtime deps
~0–280KB