#malloc #free #c #array #ffi

no-std malloced

A malloc-ed box pointer type

2 stable releases

Uses old Rust 2015

1.0.1 Dec 29, 2021
1.0.0 Dec 13, 2020

#42 in Memory management

Download history 182/week @ 2021-10-02 148/week @ 2021-10-09 178/week @ 2021-10-16 163/week @ 2021-10-23 261/week @ 2021-10-30 158/week @ 2021-11-06 1366/week @ 2021-11-13 1416/week @ 2021-11-20 1451/week @ 2021-11-27 1348/week @ 2021-12-04 1346/week @ 2021-12-11 1314/week @ 2021-12-18 1253/week @ 2021-12-25 763/week @ 2022-01-01 751/week @ 2022-01-08 734/week @ 2022-01-15

3,723 downloads per month
Used in 3 crates (via fruity__bbqsrc)

MIT/Apache

17KB
270 lines

Malloced

A malloc-ed box pointer type, brought to you by @NikolaiVazquez!

Table of Contents

  1. Donate
  2. Usage
  3. MSRV
  4. FFI Safety
  5. Alternatives
  6. License

Donate

If this project is useful to you, please consider sponsoring me or donating directly!

Doing so enables me to create high-quality open source software like this. ❤️

Usage

This library is available on crates.io and can be used by adding the following to your project's Cargo.toml:

[dependencies]
malloced = "1.0.1"

The star of the show is Malloced, Box-like pointer that calls free on Drop:

use malloced::Malloced;

MSRV

This library's minimum supported Rust version (MSRV) is 1.30. A new version requirement would result in a minor version update.

If the pin feature is enabled, the MSRV is 1.33.

FFI Safety

Malloced<T> is a #[repr(transparent)] wrapper over NonNull<T>, so it can be safely used in C FFI. For example, the following is safe and even compiles with the improper_ctypes lint enabled:

#[deny(improper_ctypes)]
extern "C" {
    fn my_array_malloc() -> Malloced<[u8; 32]>;
}

Alternatives

License

This project is released under either MIT License or Apache License (Version 2.0) at your choosing.

No runtime deps

Features

  • pin
  • std
.7a