7 stable releases

Uses old Rust 2015

1.3.1 Feb 27, 2023
1.2.0 Feb 27, 2023
1.1.0 Jan 29, 2022
1.0.1 Dec 29, 2021
1.0.0 Dec 13, 2020

#141 in Memory management

Download history 905/week @ 2024-07-22 1466/week @ 2024-07-29 1368/week @ 2024-08-05 1022/week @ 2024-08-12 1178/week @ 2024-08-19 1381/week @ 2024-08-26 962/week @ 2024-09-02 1419/week @ 2024-09-09 1119/week @ 2024-09-16 972/week @ 2024-09-23 999/week @ 2024-09-30 861/week @ 2024-10-07 1081/week @ 2024-10-14 1065/week @ 2024-10-21 1009/week @ 2024-10-28 588/week @ 2024-11-04

3,843 downloads per month
Used in 15 crates (2 directly)

MIT/Apache

26KB
536 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.3.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.64. A new version requirement would result in a minor version update.

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