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]

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]

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]

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]

The resulting type after dereferencing

The method called to dereference a value

impl<T: ?Sized> Drop for Malloc<T>
[src]

A method called when the value goes out of scope. Read more

impl<T: Debug + ?Sized> Debug for Malloc<T>
[src]

Formats the value using the given formatter.

impl<T: Display + ?Sized> Display for Malloc<T>
[src]

Formats the value using the given formatter. Read more

impl<T: ?Sized> AsRef<T> for Malloc<T>
[src]

Performs the conversion.