#[unsafe(no_mangle)]pub unsafe extern "C" fn hurray_tensor_destroy(
handle: *mut *mut HurrayTensor,
) -> HurrayStatusExpand description
Destroys a tensor handle — its descriptor, every buffer it owns, and its owner
reference — then writes null through handle.
One call rather than two, so the teardown order is not the caller’s problem. A
non-null owner_release is invoked exactly once, with the owner pointer given at
construction.
§Safety
handleMUST be a valid, non-null pointer to a*mut HurrayTensorproduced byhurray_tensor_new, byhurray_reader_next_tensor, byhurray_file_reader_read_tensor, or taken out of a native-protocol capsule.- That tensor MUST NOT have been destroyed already.
§Examples
use hurray_ffi::tensor::{hurray_tensor_destroy, hurray_tensor_new};
use hurray_ffi::{
hurray_buffer_list_new, HurrayBufferList, HurrayTensor, HURRAY_C_ABI_VERSION,
HURRAY_ERR_INTERNAL, HURRAY_OK,
};
assert_eq!(unsafe { hurray_tensor_destroy(&mut tensor) }, HURRAY_OK);
assert!(tensor.is_null());
// A second destroy finds the caller's variable dead and says so, rather than
// freeing anything twice.
assert_eq!(
unsafe { hurray_tensor_destroy(&mut tensor) },
HURRAY_ERR_INTERNAL,
);