[−][src]Struct dlmalloc::Dlmalloc
An allocator instance
Instances of this type are used to allocate blocks of memory. For best
results only use one of these. Currently doesn't implement Drop
to release
lingering memory back to the OS. That may happen eventually though!
Implementations
impl Dlmalloc<System>
[src]
impl<A> Dlmalloc<A>
[src]
pub const fn new_with_allocator(sys_allocator: A) -> Dlmalloc<A>
[src]
Creates a new instance of an allocator
impl<A: Allocator> Dlmalloc<A>
[src]
pub unsafe fn malloc(&mut self, size: usize, align: usize) -> *mut u8
[src]
Allocates size
bytes with align
align.
Returns a null pointer if allocation fails. Returns a valid pointer otherwise.
Safety and contracts are largely governed by the GlobalAlloc::alloc
method contracts.
pub unsafe fn calloc(&mut self, size: usize, align: usize) -> *mut u8
[src]
Same as malloc
, except if the allocation succeeds it's guaranteed to
point to size
bytes of zeros.
pub unsafe fn free(&mut self, ptr: *mut u8, size: usize, align: usize)
[src]
Deallocates a ptr
with size
and align
as the previous request used
to allocate it.
Safety and contracts are largely governed by the GlobalAlloc::dealloc
method contracts.
pub unsafe fn realloc(
&mut self,
ptr: *mut u8,
old_size: usize,
old_align: usize,
new_size: usize
) -> *mut u8
[src]
&mut self,
ptr: *mut u8,
old_size: usize,
old_align: usize,
new_size: usize
) -> *mut u8
Reallocates ptr
, a previous allocation with old_size
and
old_align
, to have new_size
and the same alignment as before.
Returns a null pointer if the memory couldn't be reallocated, but ptr
is still valid. Returns a valid pointer and frees ptr
if the request
is satisfied.
Safety and contracts are largely governed by the GlobalAlloc::realloc
method contracts.
Auto Trait Implementations
impl<A> Send for Dlmalloc<A> where
A: Send,
A: Send,
impl<A = System> !Sync for Dlmalloc<A>
impl<A> Unpin for Dlmalloc<A> where
A: Unpin,
A: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,