1 unstable release
Uses old Rust 2015
0.1.0 | Sep 3, 2017 |
---|
#25 in #malloc
26KB
334 lines
malloc-bind
The malloc-bind
crate provides bindings for the C malloc
API. Given an implementation of the Rust Alloc
trait, it produces implementations of the C malloc
API (malloc
, free
, realloc
, etc) and defines extern "C"
functions that can be used to produce a C shared object file.
lib.rs
:
Bindings for the C malloc
API to Rust allocators.
This crate provides a mechanism to construct a C allocator - an implementation of malloc
,
free
, and related functions - that is backed by a Rust allocator (an implementation of the
Alloc
trait).
In order to create bindings, two things must be provided: an implementation of the Alloc
trait, and an implementation of the LayoutFinder
trait (defined in this crate). Since the C
API does not provide size or alignment on free
, but the Rust Alloc
API requires both size
and alignment on dealloc
, a mapping must be maintained between allocated objects and those
objects' size and alignment. The LayoutFinder
provides this functionality.
Dependencies
~65–335KB