Struct malloc_bind::Malloc
[−]
[src]
pub struct Malloc<A, L: LayoutFinder> where
&'a A: Alloc, { /* fields omitted */ }
A wrapper for a Rust allocator providing C bindings.
Malloc
wraps existing Alloc
and LayoutFinder
instances and provides methods for each of
the various C allocation functions. Most users should simply call the define_malloc
or
define_malloc_lazy_static
macros, which take care of constructing a Malloc
instance and
defining the various extern "C"
functions of the C allocation API. Users who wish to expose
only a subset of this API will need to instantiate a Malloc
and define the extern "C"
functions manually.
Methods
impl<A, L: LayoutFinder> Malloc<A, L> where
&'a A: Alloc,
[src]
&'a A: Alloc,
const fn new(alloc: A, layout_finder: L) -> Malloc<A, L>
[src]
Construct a new Malloc
.
new
constructs a new Malloc
using the provided allocator and LayoutFinder
. Since C
allocation functions can be called from many threads simultaneously, the allocator must be
thread-safe. Thus, A
(the type of the alloc
parameter) isn't required to implement
Alloc
. Instead, &A
must implement Alloc
so that Alloc
's methods can be called
concurrently.
unsafe fn malloc(&self, size: size_t) -> *mut c_void
[src]
The C malloc
function.
unsafe fn free(&self, ptr: *mut c_void)
[src]
The C free
function.
unsafe fn cfree(&self, ptr: *mut c_void)
[src]
The obsolete C cfree
function.
unsafe fn calloc(&self, nmemb: size_t, size: size_t) -> *mut c_void
[src]
The C calloc
function.
unsafe fn valloc(&self, size: size_t) -> *mut c_void
[src]
The obsolete C valloc
function.
unsafe fn pvalloc(&self, size: size_t) -> *mut c_void
[src]
The obsolete C pvalloc
function (only implemented on Linux).
unsafe fn realloc(&self, ptr: *mut c_void, size: size_t) -> *mut c_void
[src]
The C realloc
function.
unsafe fn reallocarray(
&self,
ptr: *mut c_void,
nmemb: size_t,
size: size_t
) -> *mut c_void
[src]
&self,
ptr: *mut c_void,
nmemb: size_t,
size: size_t
) -> *mut c_void
The C reallocarray
function (only implemented on Linux).
unsafe fn posix_memalign(
&self,
memptr: *mut *mut c_void,
alignment: size_t,
size: size_t
) -> i32
[src]
&self,
memptr: *mut *mut c_void,
alignment: size_t,
size: size_t
) -> i32
The C posix_memalign
function.
unsafe fn memalign(&self, alignment: size_t, size: size_t) -> *mut c_void
[src]
The obsolete C memalign
function (only implemented on Linux).
unsafe fn aligned_alloc(&self, alignment: size_t, size: size_t) -> *mut c_void
[src]
The C aligned_alloc
function (only implemented on Linux).