Creates a Buffer from native memory.
When copy is true, the returned Buffer owns its own copied memory. When copy is false, the returned Buffer references the original native memory directly.
Using copy: false is a zero-copy escape hatch. The returned Buffer is a writable view onto foreign memory, so writes in JavaScript update the original native memory directly. The caller must guarantee that:
pointerremains valid for the entire lifetime of the returnedBuffer.lengthstays within the allocated native region.- no native code frees or repurposes that memory while JavaScript still uses the
Buffer. - Memory protection is observed. For example, read-only memory pages must not be written to.
If these guarantees are not met, reading or writing the Buffer can corrupt memory or crash the process.