[][src]Trait alloc_wg::alloc::AllocRef

pub trait AllocRef: DeallocRef {
    type Error;
    fn alloc(
        &mut self,
        layout: NonZeroLayout
    ) -> Result<NonNull<u8>, Self::Error>; fn alloc_zeroed(
        &mut self,
        layout: NonZeroLayout
    ) -> Result<NonNull<u8>, Self::Error> { ... }
fn usable_size(&self, layout: NonZeroLayout) -> (usize, usize) { ... }
unsafe fn grow_in_place(
        &mut self,
        ptr: NonNull<u8>,
        layout: NonZeroLayout,
        new_size: NonZeroUsize
    ) -> bool { ... }
unsafe fn shrink_in_place(
        &mut self,
        ptr: NonNull<u8>,
        layout: NonZeroLayout,
        new_size: NonZeroUsize
    ) -> bool { ... } }

Associated Types

type Error

Loading content...

Required methods

fn alloc(&mut self, layout: NonZeroLayout) -> Result<NonNull<u8>, Self::Error>

Loading content...

Provided methods

fn alloc_zeroed(
    &mut self,
    layout: NonZeroLayout
) -> Result<NonNull<u8>, Self::Error>

fn usable_size(&self, layout: NonZeroLayout) -> (usize, usize)

unsafe fn grow_in_place(
    &mut self,
    ptr: NonNull<u8>,
    layout: NonZeroLayout,
    new_size: NonZeroUsize
) -> bool

Safety

  • ptr must be currently allocated via this allocator
  • layout must fit the ptr (see above); note the new_size argument need not fit it
  • new_size must not be less than layout.size()

unsafe fn shrink_in_place(
    &mut self,
    ptr: NonNull<u8>,
    layout: NonZeroLayout,
    new_size: NonZeroUsize
) -> bool

Safety

  • ptr must be currently allocated via this allocator
  • layout must fit the ptr (see above); note the new_size argument need not fit it
  • new_size must not be greater than layout.size() (and must be greater than zero)
Loading content...

Implementations on Foreign Types

impl AllocRef for System[src]

type Error = AllocErr

Loading content...

Implementors

impl AllocRef for Global[src]

type Error = AllocErr

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

type Error = Never

Loading content...