Hey! How do I get a `CValuesRef<CPointerVar<...
# kotlin-native
i
Hey! How do I get a
CValuesRef<CPointerVar<ByteVar>>?
to pass to a native function?
Is this a correct way to do it?
Copy code
val byteVar = alloc<ByteVar>()
val byteVarValueRef = cValuesOf(byteVar.ptr)
s
It depends on what would you like to achieve. What does native function expect to get through this parameter? Does it require an array of pointers? Or is it going to return a pointer value by storing it into the memory pointed by this parameter?
i
Yes, it writes into memory being pointed by this parameter. Native function looks like this:
void func(unsigned char** param);
o
Copy code
fun use_func() {
 memScoped {
   val data = alloc<CPointerVar<UByteVar>>()
   func(data.ptr)
   println("got ${(data.value!!.reinterpret<ByteVar>().toKString()}")
 }
}
👍 1
i
Thank you!