#malloc #libc #allocator #no-std #memalign

no-std libc_alloc

A simple global allocator which hooks into libc's malloc/free

5 stable releases

1.0.4 Nov 11, 2022
1.0.3 Aug 4, 2021
1.0.2 Apr 24, 2020
1.0.0 Apr 23, 2020

#80 in FFI

Download history 182/week @ 2023-01-24 128/week @ 2023-01-31 115/week @ 2023-02-07 152/week @ 2023-02-14 82/week @ 2023-02-21 74/week @ 2023-02-28 192/week @ 2023-03-07 132/week @ 2023-03-14 136/week @ 2023-03-21 89/week @ 2023-03-28 117/week @ 2023-04-04 53/week @ 2023-04-11 91/week @ 2023-04-18 113/week @ 2023-04-25 223/week @ 2023-05-02 200/week @ 2023-05-09

638 downloads per month

MIT license

6KB
82 lines

libc_alloc

A simple global allocator for Rust which hooks into libc. Useful when linking no_std + alloc code into existing embedded C code.

On Unix-like OSs, use posix_memalign for allocations, realloc for reallocations, and free for deallocations.

On Windows, use native _aligned_malloc for allocations, _aligned_realloc for reallocations, and _aligned_free for deallocations.

Example

use libc_alloc::LibcAlloc;

#[global_allocator]
static ALLOCATOR: LibcAlloc = LibcAlloc;

Project Status

Given how dead-simple this crate is, I doubt it will need to be updated very often (if at all).

Please file an issue and/or open a PR if you spot a bug / if something stops working.

No runtime deps