[−][src]Struct buddy_allocator::BuddyAllocator
Implementations
impl<AR: AllocRef + Copy> BuddyAllocator<AR>
[src]
pub fn try_new(
max_order: usize,
multiplier: usize,
max_idx: Option<usize>,
allocator: AR
) -> Result<Self, AllocErr>
[src]
max_order: usize,
multiplier: usize,
max_idx: Option<usize>,
allocator: AR
) -> Result<Self, AllocErr>
try to create a new buddy allocator
see Buddies::new
#![feature(allocator_api)] use alloc_wg::alloc::Global; use alloc_wg::boxed::Box; use buddy_allocator::BuddyAllocator; let allocator = BuddyAllocator::try_new(5, 16, None, Global).unwrap(); let boxed = Box::new_in(123, &allocator);
pub fn try_with_capacity(
capacity: usize,
multiplier: usize,
allocator: AR
) -> Result<Self, AllocErr>
[src]
capacity: usize,
multiplier: usize,
allocator: AR
) -> Result<Self, AllocErr>
try to create a new buddy allocator
#![feature(allocator_api)] use alloc_wg::alloc::Global; use alloc_wg::boxed::Box; use buddy_allocator::BuddyAllocator; let allocator = BuddyAllocator::try_with_capacity(320, 16, Global).unwrap(); let boxed = Box::new_in(16, &allocator);
pub fn base_ptr(&self) -> NonNull<u8>
[src]
get the base ptr
#![feature(allocator_api)] use alloc_wg::alloc::Global; use buddy_allocator::BuddyAllocator; let allocator = BuddyAllocator::try_new(5, 16, None, Global).unwrap(); allocator.base_ptr();
pub fn capacitiy(&self) -> usize
[src]
get the capacitiy
#![feature(allocator_api)] use alloc_wg::alloc::Global; use buddy_allocator::BuddyAllocator; let allocator = BuddyAllocator::try_new(5, 16, None, Global).unwrap(); assert_eq!(allocator.capacitiy(), 256);
pub fn allocate_at(
&self,
ptr: NonNull<u8>,
layout: Layout,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
[src]
&self,
ptr: NonNull<u8>,
layout: Layout,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
try to allocate the memory at the given ptr
Trait Implementations
impl<'_, AR: AllocRef + Copy> AllocRef for &'_ BuddyAllocator<AR>
[src]
fn alloc(
&mut self,
layout: Layout,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
[src]
&mut self,
layout: Layout,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout)
[src]
unsafe fn grow(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize,
placement: ReallocPlacement,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
[src]
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize,
placement: ReallocPlacement,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
unsafe fn shrink(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize,
_: ReallocPlacement
) -> Result<MemoryBlock, AllocErr>
[src]
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize,
_: ReallocPlacement
) -> Result<MemoryBlock, AllocErr>
fn by_ref(&mut self) -> &mut Self
[src]
impl<AR: AllocRef> Drop for BuddyAllocator<AR>
[src]
impl<AR: AllocRef + Send> Send for BuddyAllocator<AR>
[src]
impl<AR: AllocRef + Sync> Sync for BuddyAllocator<AR>
[src]
Auto Trait Implementations
impl<AR> RefUnwindSafe for BuddyAllocator<AR> where
AR: RefUnwindSafe,
AR: RefUnwindSafe,
impl<AR> Unpin for BuddyAllocator<AR> where
AR: Unpin,
AR: Unpin,
impl<AR> UnwindSafe for BuddyAllocator<AR> where
AR: UnwindSafe,
AR: UnwindSafe,
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,
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.
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>,