playXE / alloca-rs

Mostly safe wrapper for alloca

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

alloca-rs

Build Status Latest Version Documentation

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);
    });
}

About

Mostly safe wrapper for alloca

License:MIT License


Languages

Language:Rust 93.2%Language:C 6.8%