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]

[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.

[src]

The C malloc function.

[src]

The C free function.

[src]

The obsolete C cfree function.

[src]

The C calloc function.

[src]

The obsolete C valloc function.

[src]

The obsolete C pvalloc function (only implemented on Linux).

[src]

The C realloc function.

[src]

The C reallocarray function (only implemented on Linux).

[src]

The C posix_memalign function.

[src]

The obsolete C memalign function (only implemented on Linux).

[src]

The C aligned_alloc function (only implemented on Linux).