Or if you want a `ByteArray`, you can `memcpy` fro...
# kotlin-native
c
Or if you want a
ByteArray
, you can
memcpy
from that `CPointer<ByteVar>`:
Copy code
val ptr: CPointer<ByteVar> = ...
val byteArray = ByteArray(bufferSize).apply {
  usePinned { pinned ->
    memcpy(pinned.getAddress(0), ptr, bufferSize) 
  }
}
j
ptr.readBytes(bufferSize)
will do all that for you and return a
ByteArray
👍 2
c
@jw I'm actually `memcpy`ing for the same scenario but with
CharArray
, is there a simple method like
ptr.readBytes
but for
CharArray
? I can see there is an internal method for that, but not a public one...