napi_create_external_buffer

Function napi_create_external_buffer 

Source
pub unsafe extern "C" fn napi_create_external_buffer(
    env: napi_env,
    length: usize,
    data: *mut c_void,
    finalize_cb: napi_finalize,
    finalize_hint: *mut c_void,
    result: *mut napi_value,
) -> napi_status
Available on crate feature napi only.
Expand description

Creates an ArkTS ArrayBuffer object of the specified size and initializes it with the given data.

§Arguments

  • env - Current running virtual machine context.n

  • length - Bytes size of the given data.

  • data - Given data.

  • finalize_cb - Optional native callback that can be used to free the given data when the ArkTS ArrayBuffer object has been garbage-collected.

  • finalize_hint - Optional contextual hint that is passed to the finalize callback.

  • result - Created ArkTS ArrayBuffer object.

§Returns

  • Returns the function execution status. [napi_ok] If the function executed successfully.

[napi_invalid_arg] If env, data or result is nullptr, or length is larger than 2097152, or length is less than or equal to zero.

[napi_pending_exception] If an ArkTS exception existed when the function was called.

Available since API-level: 10