[][src]Trait alloc_wg::alloc::ReallocRef

pub trait ReallocRef: AllocRef {
    unsafe fn realloc(
        &mut self,
        ptr: NonNull<u8>,
        old_layout: NonZeroLayout,
        new_layout: NonZeroLayout
    ) -> Result<NonNull<u8>, Self::Error> { ... } }

Provided methods

unsafe fn realloc(
    &mut self,
    ptr: NonNull<u8>,
    old_layout: NonZeroLayout,
    new_layout: NonZeroLayout
) -> Result<NonNull<u8>, Self::Error>

Safety

  • ptr must be currently allocated via this allocator,
  • layout must fit the ptr (see above). (The new_size argument need not fit it.)
  • new_size, when rounded up to the nearest multiple of layout.align(), must not overflow (i.e., the rounded value must be less than usize::MAX).

(Extension subtraits might provide more specific bounds on behavior, e.g., guarantee a sentinel address or a null pointer in response to a zero-size allocation request.)

Errors

Returns Err only if the new layout does not meet the allocator's size and alignment constraints of the allocator, or if reallocation otherwise fails.

Implementations are encouraged to return Err on memory exhaustion rather than panicking or aborting, but this is not a strict requirement. (Specifically: it is legal to implement this trait atop an underlying native allocation library that aborts on memory exhaustion.)

Loading content...

Implementations on Foreign Types

impl ReallocRef for System[src]

Loading content...

Implementors

impl ReallocRef for Global[src]

impl<A: ReallocRef> ReallocRef for AbortAlloc<A>[src]

Loading content...