#[unsafe(no_mangle)]pub unsafe extern "C" fn hurray_tensor_context_destroy(
ctx: *mut *mut HurrayTensorContext,
) -> HurrayStatusExpand description
Destroys a HurrayTensorContext, invoking its owner-release callback, and
nulls the caller’s pointer.
Destroying a null handle is a no-op that returns HURRAY_OK, so the call
is safe to make unconditionally on a cleanup path.
§Safety
ctxMUST be a valid, writable pointer to a handle slot.- The handle it points to MUST come from
hurray_tensor_context_newand MUST NOT have been destroyed already.
§Examples
use hurray_ffi::tensor_context::{hurray_tensor_context_destroy, hurray_tensor_context_new};
use hurray_ffi::{HurrayTensorContext, HURRAY_C_ABI_VERSION, HURRAY_OK};
let mut ctx: *mut HurrayTensorContext = std::ptr::null_mut();
unsafe {
hurray_tensor_context_new(
HURRAY_C_ABI_VERSION, std::ptr::null(), 0, std::ptr::null_mut(), None, &mut ctx,
);
}
assert_eq!(unsafe { hurray_tensor_context_destroy(&mut ctx) }, HURRAY_OK);
assert!(ctx.is_null());
// Destroying again is a no-op, not a double free.
assert_eq!(unsafe { hurray_tensor_context_destroy(&mut ctx) }, HURRAY_OK);