nativeMain.kotlinx.io.core.BytePacketBuilderNative.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlinx-io-linuxx64 Show documentation
Show all versions of kotlinx-io-linuxx64 Show documentation
IO support libraries for Kotlin
package kotlinx.io.core
import kotlinx.io.pool.*
import kotlinx.cinterop.*
import kotlinx.io.core.internal.*
@DangerousInternalIoApi
@Deprecated("Will be removed in future releases.")
@Suppress("DEPRECATION_ERROR")
actual abstract class BytePacketBuilderPlatformBase
internal actual constructor(pool: ObjectPool) : BytePacketBuilderBase(pool) {
final override fun writeFully(src: CPointer, offset: Int, length: Int) {
writeFully(src, offset.toLong(), length.toLong())
}
final override fun writeFully(src: CPointer, offset: Long, length: Long) {
require(length >= 0L)
require(offset >= 0L)
var position = offset
var rem = length
writeWhile { chunk ->
val size = minOf(chunk.writeRemaining.toLong(), rem)
chunk.writeFully(src, position, size)
position += size
rem -= size
rem > 0
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy