#[no_mangle]
pub unsafe extern "C" fn nstd_alloc_deallocate(
    ptr: &mut NSTDAnyMut,
    size: NSTDUInt
) -> NSTDAllocError
Available on crate feature alloc only.
Expand description

Deallocates a block of memory previously allocated by nstd_alloc_allocate[_zeroed].

Parameters:

  • NSTDAnyMut *ptr - A pointer to the allocated memory, once freed the pointer is set to null.

  • NSTDUInt size - The number of bytes to free.

Returns

NSTDAllocError errc - The allocation operation error code.

Safety

  • Behavior is undefined if ptr is not a value returned by nstd_alloc_allocate[_zeroed].

  • size must be the same value that was used to allocate the memory buffer.

Example

use nstd_sys::alloc::{nstd_alloc_allocate, nstd_alloc_deallocate};

unsafe {
    let mut mem = nstd_alloc_allocate(24);
    assert!(!mem.is_null());
    nstd_alloc_deallocate(&mut mem, 24);
}