Giter Club home page Giter Club logo

alloca-rs's Introduction

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

alloca-rs's People

Contributors

playxe avatar pro465 avatar pseitz avatar slerpyyy avatar stackoverflowexcept1on avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

alloca-rs's Issues

Compilation fails on wasm32-wasi

There's a CI that fails compiling.
https://github.com/bheisler/criterion.rs/actions/runs/5087853945/jobs/9143622887?pr=686

I'm not sure how to handle that on wasm. Probably put it behind a conditional compilation block, to not use alloca.
I think compilation failing would still be a blocker, since the crate will still be compiled.

Reproduce

cargo build --target=wasm32-wasi

โžœ  alloca-rs git:(main) cargo build --target=wasm32-wasi
  Downloaded cc v1.0.66
  Downloaded 1 crate (53.5 KB) in 1.23s
   Compiling cc v1.0.66
   Compiling alloca v0.3.3 (/home/pascal/LinuxData/Development/alloca-rs)
The following warnings were emitted during compilation:

warning: In file included from alloca_.c:2:
warning: /usr/lib/clang/15.0.7/include/inttypes.h:21:15: fatal error: 'inttypes.h' file not found
warning: #include_next <inttypes.h>
warning:               ^~~~~~~~~~~~
warning: 1 error generated.

error: failed to run custom build command for `alloca v0.3.3 (/home/pascal/LinuxData/Development/alloca-rs)`

Caused by:
  process didn't exit successfully: `/home/pascal/LinuxData/Development/alloca-rs/target/debug/build/alloca-3a7601d31ad37651/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("wasm32-wasi")
  HOST = Some("x86_64-unknown-linux-gnu")
  CC_wasm32-wasi = None
  CC_wasm32_wasi = None
  TARGET_CC = None
  CC = None
  CFLAGS_wasm32-wasi = None
  CFLAGS_wasm32_wasi = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  running: "clang" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-wasi" "-Wall" "-Wextra" "-o" "/home/pascal/LinuxData/Development/alloca-rs/target/wasm32-wasi/debug/build/alloca-7637b6b4aaef8e8b/out/alloca_.o" "-c" "alloca_.c"
  cargo:warning=In file included from alloca_.c:2:
  cargo:warning=/usr/lib/clang/15.0.7/include/inttypes.h:21:15: fatal error: 'inttypes.h' file not found
  cargo:warning=#include_next <inttypes.h>
  cargo:warning=              ^~~~~~~~~~~~
  cargo:warning=1 error generated.
  exit status: 1

  --- stderr


  error occurred: Command "clang" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-wasi" "-Wall" "-Wextra" "-o" "/home/pascal/LinuxData/Development/alloca-rs/target/wasm32-wasi/debug/build/alloca-7637b6b4aaef8e8b/out/alloca_.o" "-c" "alloca_.c" with args "clang" did not execute successfully (status code exit status: 1).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.