Function mozjs::jsapi::JS::GetArrayBufferMaybeSharedData

source ·
pub unsafe extern "C" fn GetArrayBufferMaybeSharedData(
    obj: *mut JSObject,
    isSharedMemory: *mut bool,
    arg1: *const AutoRequireNoGC,
) -> *mut u8
Expand description

Return a pointer to the start of the array buffer’s data, and indicate whether the data is from a shared array buffer through an outparam.

The returned data pointer may be invalidated by a GC or by an unshared array buffer becoming detached. Callers must take care not to perform any actions that could trigger a GC or result in an unshared array buffer becoming detached. If such actions nonetheless must be performed, callers should perform this call a second time (and sensibly handle results that may be different from those returned the first time). (Sharedness is an immutable characteristic of an array buffer or shared array buffer, so that boolean remains valid across GC or detaching.)

|obj| must have passed a JS::IsArrayBufferObjectMaybeShared test, or somehow be known that it would pass such a test: it is an ArrayBuffer or SharedArrayBuffer or a wrapper of an ArrayBuffer/SharedArrayBuffer, and the unwrapping will succeed.

|*isSharedMemory| will be set to true if the typed array maps a SharedArrayBuffer, otherwise to false.