libc_alloc

Crates.iolibc_alloc
lib.rslibc_alloc
version1.0.7
sourcesrc
created_at2020-04-23 23:54:26.67104
updated_at2024-03-19 15:44:17.664712
descriptionA simple global allocator which hooks into libc's malloc/free
homepagehttps://github.com/daniel5151/libc_alloc
repositoryhttps://github.com/daniel5151/libc_alloc
max_upload_size
id233457
size8,535
Daniel Prilik (daniel5151)

documentation

https://docs.rs/libc_alloc

README

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.

Commit count: 18

cargo fmt