64 * 1024 val buffer = allocArray<ByteVar>(bufferLength) for (i in 1..count) { val nextLine = fgets(buffer, bufferLength, file)? .toKString() ... } } 動的確保した部分はmemScopedを抜 けると自動的にfreeされる
arrayOf(1, 2, 3) for(i in 0..3) println(arr[i]) memScoped { val arr = intArrayOf(1, 2, 3) .toCValues() .getPointer(this) for (i in 0..3) println(arr[i]) }