I'm trying to pass a Scala array to native code and need to do the conversion. How to convert Array[Byte]
to Ptr[Byte]
in Scala Native?
Asked
Active
Viewed 47 times
0

R A
- 149
- 1
- 9
1 Answers
0
My best solution so far is this:
def makeNativeArray(input: Array[Byte])(using z: Zone): Ptr[Byte] =
val rawSize = input.length
val buffer = alloc[Byte](rawSize)
for i <- 0 until rawSize
do
buffer(i) = input(i)
buffer

R A
- 149
- 1
- 9