ffi.toArrayBuffer(pointer, length[, copy])
pointer<bigint>length<number>copy<boolean> 当false,创建一个零拷贝视图。默认:true。- 返回:<ArrayBuffer>
从本地内存创建一个 ArrayBuffer。
🌐 Creates an ArrayBuffer from native memory.
当 copy 为 true 时,返回的 ArrayBuffer 包含复制的字节。
当 copy 为 false 时,返回的 ArrayBuffer 直接引用原始本地内存。
🌐 When copy is true, the returned ArrayBuffer contains copied bytes.
When copy is false, the returned ArrayBuffer references the original
native memory directly.
与 ffi.toBuffer(pointer, length, copy) 描述的相同生命周期和边界要求适用于这里。使用 copy: false 时,返回的 ArrayBuffer 是对外部内存的零拷贝视图,并且只有在该内存保持分配状态、布局未改变且在整个暴露范围内有效时才安全。
🌐 The same lifetime and bounds requirements described for
ffi.toBuffer(pointer, length, copy) apply
here. With copy: false, the
returned ArrayBuffer is a zero-copy view of foreign memory and is only safe
while that memory remains allocated, unchanged in layout, and valid for the
entire exposed range.