#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

#88 in Embedded development

Download history 1572/week @ 2024-02-15 2488/week @ 2024-02-22 1865/week @ 2024-02-29 2251/week @ 2024-03-07 2939/week @ 2024-03-14 2784/week @ 2024-03-21 2477/week @ 2024-03-28 2310/week @ 2024-04-04 3174/week @ 2024-04-11 2986/week @ 2024-04-18 1725/week @ 2024-04-25 2457/week @ 2024-05-02 1827/week @ 2024-05-09 2021/week @ 2024-05-16 3016/week @ 2024-05-23 2783/week @ 2024-05-30

10,041 downloads per month
Used in icu_capi

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