Skip to main content

hurray_buffer_from_ptr

Function hurray_buffer_from_ptr 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hurray_buffer_from_ptr( data: *mut c_void, byte_size: u64, alignment: u32, device_tag: u8, sync_mode: u8, memory_class: u8, release: HurrayReleaseCallback, release_context: *mut c_void, out_handle: *mut *mut HurrayBuffer, ) -> HurrayStatus
Expand description

Creates a new HurrayBuffer handle from a raw data pointer and metadata.

The caller retains ownership of data until the handle is destroyed via hurray_buffer_destroy, at which point the release callback (if non-null) is invoked with (data, release_context). If release is null, the caller is responsible for freeing data after destroying the handle.

§Arguments

  • data — Non-null pointer to the first byte of the buffer. MUST be aligned to at least alignment bytes.
  • byte_size — Length of the buffer in bytes.
  • alignment — Declared alignment of data in bytes; MUST be a power of two and at least hurray_core::MIN_BUFFER_ALIGNMENT for non-empty buffers.
  • device_tag — Wire byte identifying the memory space (see docs/spec/buffer-protocol.md § Device Tags).
  • sync_mode — Wire byte for producer/consumer ordering (see docs/spec/buffer-protocol.md § Synchronization Mode).
  • memory_class — Wire byte for memory accessibility class.
  • release — Optional callback invoked on hurray_buffer_destroy.
  • release_context — Opaque context pointer forwarded to release; MAY be null.
  • out_handle — Non-null pointer to a *mut HurrayBuffer; set to the newly allocated handle on success.

§Safety

  • data MUST be a valid, non-null pointer to at least byte_size bytes.
  • data MUST remain valid until the release callback is called.
  • out_handle MUST be a valid, non-null, writable pointer.
  • release_context lifetime is caller-managed; it MUST remain valid until the release callback returns.