ffi.toArrayBuffer(pointer, length[, copy])


从本地内存创建一个 ArrayBuffer

🌐 Creates an ArrayBuffer from native memory.

copytrue 时,返回的 ArrayBuffer 包含复制的字节。 当 copyfalse 时,返回的 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.