isnt in there. I think for the most part I just stick to lists when doing KMM work
l
Landry Norris
01/18/2023, 7:01 PM
C methods typically handle arrays as pointers, where you have to get the size separately. This would make it difficult for Kotlin to convert to an Array, which has to have a specified size in Kotlin.
Landry Norris
01/18/2023, 7:04 PM
I typically write an extension for different CPointer types
CPointer<Something>.toArray(size: Int)
, but different libraries have different ways of determining size, so this has to be written manually, and is also unsafe, as it relies on the assumption that the size is correct. An incorrect size value can lead to very difficult to debug problems.
Landry Norris
01/18/2023, 7:06 PM
I personally wish that there would be a built-in version of the method I mentioned that can more efficiently copy the bytes (or even use immutable collections to just wrap the original C array), but I doubt that JB would provide this because it’s inherently unsafe.
a
andylamax
01/18/2023, 9:27 PM
I just stick to List...
Its all fine sticking with Lists until you start targeting Javascript as well. That's where it all fails hard