All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nativeMain.kotlinx.io.core.BytePacketBuilderNative.kt Maven / Gradle / Ivy

There is a newer version: 0.1.16
Show newest version
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