pub struct Malloc<T: ?Sized> { /* private fields */ }
Expand description
A type that represents a malloc
’d chunk of memory.
When dropped, a Malloc
will free
that memory.
Implementations§
Source§impl<T> Malloc<[T]>
impl<T> Malloc<[T]>
Sourcepub unsafe fn from_array(ptr: *mut T, len: usize) -> Malloc<[T]>
pub unsafe fn from_array(ptr: *mut T, len: usize) -> Malloc<[T]>
Constructs a new Malloc
for a malloc
’d buffer with the given length
at the given pointer.
Unsafe because there must be len
contiguous, valid instances of T
at ptr
.
The given pointer must not be null unless the length is 0; this function will specially handle null, 0-length buffers safely.
Source§impl Malloc<str>
impl Malloc<str>
Sourcepub unsafe fn from_c_str(ptr: *mut c_char) -> Result<Malloc<str>, Utf8Error>
pub unsafe fn from_c_str(ptr: *mut c_char) -> Result<Malloc<str>, Utf8Error>
Constructs a new Malloc
for a malloc
’d nul-terminated C string
at the given pointer. Returns an error if the bytes are not valid UTF8.
Unsafe because ptr
must point to valid, nul-terminated bytes.
Once created, when dereferenced the Malloc<str>
will return the string
without its nul-terminator.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Malloc<T>where
T: ?Sized,
impl<T> RefUnwindSafe for Malloc<T>where
T: RefUnwindSafe + ?Sized,
impl<T> !Send for Malloc<T>
impl<T> !Sync for Malloc<T>
impl<T> Unpin for Malloc<T>where
T: ?Sized,
impl<T> UnwindSafe for Malloc<T>where
T: RefUnwindSafe + ?Sized,
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
Mutably borrows from an owned value. Read more