Struct malloc_buf::Malloc
[−]
[src]
pub struct Malloc<T: ?Sized> { /* fields omitted */ }
A type that represents a malloc
'd chunk of memory.
When dropped, a Malloc
will free
that memory.
Methods
impl<T> Malloc<T>
[src]
unsafe fn from_ptr(ptr: *mut T) -> Malloc<T>
Constructs a new Malloc
for a malloc
'd value.
Unsafe because there must be a valid instance of T
at ptr
.
impl<T> Malloc<[T]>
[src]
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.
impl Malloc<str>
[src]
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
impl<T: ?Sized> Deref for Malloc<T>
[src]
type Target = T
The resulting type after dereferencing
fn deref(&self) -> &T
The method called to dereference a value
impl<T: ?Sized> Drop for Malloc<T>
[src]
impl<T: Debug + ?Sized> Debug for Malloc<T>
[src]
impl<T: Display + ?Sized> Display for Malloc<T>
[src]
impl<T: ?Sized> AsRef<T> for Malloc<T>
[src]
fn as_ref(&self) -> &T
Performs the conversion.