Dominaezzz
10/06/2018, 11:44 AMArray<Buffer>
object. The Buffer
class has a COpaquePointer
property and I wanna pass a temp array of these pointers to a C function. There are 2 ways to do this, cValuesOf(...)
and memScope { allocArray(...) { ... } }
, which should I prefer and when?olonho
10/07/2018, 6:54 AMCOpaquePointer
points somewhere, so question is how long you want that pointer to live. If as long, as the buffer itself, right approach would be to allocate pointer with arena, and dispose arena in special dispose method. See how disposable objects are managed in videoplayer sample: https://github.com/JetBrains/kotlin-native/blob/10b05b6229d99faaa97eaf92ae63d5da97e9be8c/samples/videoplayer/src/main/kotlin/SDLVideo.kt#L37Dominaezzz
10/07/2018, 10:02 AMBuffer
class already has its COpaquePointer
pointing to somewhere. I want to pass an array of all the buffer pointers to a C function. This array's lifetime is independent of the buffer's lifetime.Dominaezzz
10/07/2018, 10:04 AMolonho
10/07/2018, 12:05 PMcValuesOf()
or Array.toCValues()
is the way to go