Skip to main content

hurray_buffer_list_destroy

Function hurray_buffer_list_destroy 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hurray_buffer_list_destroy( list: *mut *mut HurrayBufferList, ) -> HurrayStatus
Expand description

Destroys *list and every HurrayBuffer it owns, then writes null through list.

Nulling the caller’s pointer is the sound half of Arrow’s “release marks the structure released” discipline: the list allocation itself is freed here, so a marker written inside it could not be read back, but the caller’s own variable can be invalidated.

Each owned slot is nulled as its handle is destroyed, so a release callback that panics or re-enters cannot cause a double free. A panicking callback leaks the remainder of the list rather than corrupting it.

Passing a pointer to a null pointer is a no-op and returns HURRAY_OK, which makes cleanup paths idempotent.

§Safety

  • list MUST be a valid, non-null, writable pointer to a *mut HurrayBufferList.
  • *list MUST be a live handle from hurray_buffer_list_new, or null.

§Examples

use hurray_ffi::buffer_list::{hurray_buffer_list_destroy, hurray_buffer_list_new};
use hurray_ffi::{HurrayBufferList, HURRAY_OK};

let mut list: *mut HurrayBufferList = std::ptr::null_mut();
unsafe { hurray_buffer_list_new(0, &mut list) };

assert_eq!(unsafe { hurray_buffer_list_destroy(&mut list) }, HURRAY_OK);
assert!(list.is_null());

// Idempotent: destroying an already-nulled pointer is a no-op.
assert_eq!(unsafe { hurray_buffer_list_destroy(&mut list) }, HURRAY_OK);