pub unsafe extern "C" fn NewArrayBufferWithContents(
    cx: *mut JSContext,
    nbytes: usize,
    contents: *mut c_void
) -> *mut JSObject
Expand description

Create a new ArrayBuffer with the given |contents|, which may be null only if |nbytes == 0|. |contents| must be allocated compatible with deallocation by |JS_free|.

If and only if an ArrayBuffer is successfully created and returned, ownership of |contents| is transferred to the new ArrayBuffer.

Care must be taken that |nbytes| bytes of |content| remain valid for the duration of this call. In particular, passing the length/pointer of existing typed array or ArrayBuffer data is generally unsafe: if a GC occurs during a call to this function, it could move those contents to a different location and invalidate the provided pointer.