Better reading to buffer in example.
This commit is contained in:
@@ -30,11 +30,9 @@ object Config {
|
|||||||
val file = fopen("config.txt", "r")
|
val file = fopen("config.txt", "r")
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
try {
|
try {
|
||||||
memScoped {
|
val buffer = ByteArray(2 * 1024)
|
||||||
val bufferLength = 2 * 1024
|
|
||||||
val buffer = allocArray<ByteVar>(bufferLength)
|
|
||||||
while (true) {
|
while (true) {
|
||||||
val nextLine = fgets(buffer, bufferLength, file)?.toKString()
|
val nextLine = fgets(buffer.refTo(0), buffer.size, file)?.toKString()
|
||||||
if (nextLine == null || nextLine.isEmpty()) break
|
if (nextLine == null || nextLine.isEmpty()) break
|
||||||
val records = nextLine.split('=')
|
val records = nextLine.split('=')
|
||||||
if (records.size != 2) continue
|
if (records.size != 2) continue
|
||||||
@@ -46,7 +44,6 @@ object Config {
|
|||||||
"startLevel" -> startLevel = value.toInt()
|
"startLevel" -> startLevel = value.toInt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
fclose(file)
|
fclose(file)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user