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

no-std libc_alloc

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

8 stable releases

1.0.7 Mar 19, 2024
1.0.6 Jan 6, 2024
1.0.5 Jul 25, 2023
1.0.4 Nov 11, 2022
1.0.2 Apr 24, 2020

#92 in Embedded development

Download history 368/week @ 2024-01-03 829/week @ 2024-01-10 1041/week @ 2024-01-17 1136/week @ 2024-01-24 1363/week @ 2024-01-31 1343/week @ 2024-02-07 1653/week @ 2024-02-14 2207/week @ 2024-02-21 1873/week @ 2024-02-28 2336/week @ 2024-03-06 2886/week @ 2024-03-13 2641/week @ 2024-03-20 2714/week @ 2024-03-27 2044/week @ 2024-04-03 3073/week @ 2024-04-10 2793/week @ 2024-04-17

11,336 downloads per month

MIT license

8KB
101 lines

libc_alloc

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

On Unix-like OSs, use memalign for allocations, and free for deallocations.

On macOS, use posix_memalign for allocations, 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;

Alternatively, with the global Cargo feature, the crate only needs to be pulled in:

extern crate libc_alloc;

Project Status

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

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

No runtime deps

Features