Skip to main content

JS_NewArrayBuffer

Function JS_NewArrayBuffer 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn JS_NewArrayBuffer( ctx: *mut JsContext, buf: *mut u8, len: usize, free_func: FreeArrayBufferDataFunc, opaque: *mut c_void, is_shared: Bool, ) -> JsValue
Expand description

JS_NewArrayBuffer: an ArrayBuffer over buf, taking ownership of it.

buf may be null, which asks for a zero-filled buffer of len bytes — the reference’s behaviour, and the only way to build a buffer whose contents C fills in later.

free_func is called immediately after the bytes are copied; see the module docs for why.

§Safety

buf must be null or point at len readable bytes it is safe to release through free_func.