pub struct AlignedAllocator;Expand description
Aligned memory allocator for SIMD operations.
Zero-sized: holds no state. All calls delegate to the global allocator
via std::alloc, which routes through whatever #[global_allocator]
is registered (mimalloc when the mimalloc feature is enabled, otherwise
the system allocator).
Implementations§
Source§impl AlignedAllocator
impl AlignedAllocator
Sourcepub unsafe fn alloc_aligned(
&self,
size: usize,
alignment: usize,
) -> DomainResult<NonNull<u8>>
pub unsafe fn alloc_aligned( &self, size: usize, alignment: usize, ) -> DomainResult<NonNull<u8>>
Allocate size bytes aligned to alignment (must be a power of two).
Returns a non-null pointer owned by the caller. The caller must
deallocate it via AlignedAllocator::dealloc_aligned with the same
Layout.
§Safety
The returned pointer is valid for size bytes. The caller is
responsible for ensuring the pointer is not used after deallocation.
Sourcepub unsafe fn realloc_aligned(
&self,
ptr: NonNull<u8>,
old_layout: Layout,
new_size: usize,
) -> DomainResult<NonNull<u8>>
pub unsafe fn realloc_aligned( &self, ptr: NonNull<u8>, old_layout: Layout, new_size: usize, ) -> DomainResult<NonNull<u8>>
Reallocate to new_size, preserving the original alignment.
§Safety
ptr must have been returned by AlignedAllocator::alloc_aligned
with old_layout. After this call, ptr is no longer valid —
use the returned pointer instead.
Sourcepub unsafe fn dealloc_aligned(&self, ptr: NonNull<u8>, layout: Layout)
pub unsafe fn dealloc_aligned(&self, ptr: NonNull<u8>, layout: Layout)
Deallocate memory previously returned by AlignedAllocator::alloc_aligned.
§Safety
ptr must have been returned by AlignedAllocator::alloc_aligned
with exactly layout. Double-free or mismatched layout is undefined
behavior.
Trait Implementations§
Source§impl Clone for AlignedAllocator
impl Clone for AlignedAllocator
Source§fn clone(&self) -> AlignedAllocator
fn clone(&self) -> AlignedAllocator
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AlignedAllocator
impl Debug for AlignedAllocator
Source§impl Default for AlignedAllocator
impl Default for AlignedAllocator
Source§fn default() -> AlignedAllocator
fn default() -> AlignedAllocator
impl Copy for AlignedAllocator
Auto Trait Implementations§
impl Freeze for AlignedAllocator
impl RefUnwindSafe for AlignedAllocator
impl Send for AlignedAllocator
impl Sync for AlignedAllocator
impl Unpin for AlignedAllocator
impl UnsafeUnpin for AlignedAllocator
impl UnwindSafe for AlignedAllocator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more