napperley
08/01/2021, 3:52 AM// ...
internal fun CPointer<FILE>.readLine(): String = memScoped {
val buffer = alloc<CPointerVar<ByteVar>>()
val len = alloc<ULongVar>()
val bytesRead = getline(__lineptr = buffer.ptr, __n = len.ptr, __stream = this@readLine)
if (bytesRead != -1L) buffer.value?.toKString() ?: "" else ""
}
In the code there is a minor issue where a C pointer has been allocated (via the KotlinX C Interop library), but isn't being used by anything (outside of the getline function). It would be nice if the Kotlin IntelliJ plugin could detect some issues with C interop, and show them as warnings (yellow squigglies), or even better provide some quick fixes for the ones that can be easily fixed.Alexey Belkov [JB]
08/26/2021, 2:24 PMArtyom Degtyarev [JB]
08/26/2021, 2:31 PM