Struct winsafe::guard::HeapFreeGuard
source · pub struct HeapFreeGuard<'a, H>where
H: kernel_Hheap,{ /* private fields */ }
kernel
only.Expand description
RAII implementation for the memory allocated by
HHEAP::HeapAlloc
which
automatically calls
HeapFree
when the object goes out of scope.
Implementations§
source§impl<'a, H> HeapFreeGuard<'a, H>where
H: kernel_Hheap,
impl<'a, H> HeapFreeGuard<'a, H>where
H: kernel_Hheap,
sourcepub fn leak(&mut self) -> (*mut c_void, usize)
pub fn leak(&mut self) -> (*mut c_void, usize)
Ejects the underlying memory pointer and size, leaving null and zero in their places.
Since the internal memory pointer will be invalidated, the destructor will not run. It’s your responsibility to run it, otherwise you’ll cause a memory leak.
sourcepub const fn as_ptr(&self) -> *const c_void
pub const fn as_ptr(&self) -> *const c_void
Returns a pointer to the allocated memory block, or null if not allocated.
sourcepub fn as_mut_ptr(&mut self) -> *mut c_void
pub fn as_mut_ptr(&mut self) -> *mut c_void
Returns a mutable pointer to the allocated memory block, or null if not allocated.
sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Returns a mutable slice over the allocated memory block.
sourcepub const unsafe fn as_slice_aligned<T>(&self) -> &[T]
pub const unsafe fn as_slice_aligned<T>(&self) -> &[T]
Returns a slice over the allocated memory block, aligned to the given type.
§Safety
Make sure the alignment is correct.
sourcepub unsafe fn as_mut_slice_aligned<T>(&mut self) -> &mut [T]
pub unsafe fn as_mut_slice_aligned<T>(&mut self) -> &mut [T]
Returns a mutable slice over the allocated memory block, aligned to the given type.
§Safety
Make sure the alignment is correct.