I have library, that has function with header like
int func(const char* src...);
that I use with cinterop. I want to pass inside
CPointer<ByteVar>
or
CPointer<UByteVar>
as a parameter (because char* is pointer to char) that a aquired from previous native call. However the function has in kotlin binding header
public fun func(source: kotlin.String?...
accepting kotlin string. How do I do it? Do I need to call
toKString()
? Doesn't
toKString()
involve some allocation? Does it correctly translates the
CPointer<ByteVar>
buffer to string (without some corruption due to encoding for example)? Isn't it useless step as the KString will have to be translated back to C char array later?