This commit is contained in:
minjaesong
2023-01-14 22:59:27 +09:00
parent 994db188c2
commit 0eb4a1e4ea
4 changed files with 1094 additions and 5 deletions

View File

@@ -230,6 +230,8 @@ class VM(
}
internal fun malloc(size: Int): Int {
if (size <= 0) throw IllegalArgumentException("Invalid malloc size: $size")
val allocBlocks = ceil(size.toDouble() / MALLOC_UNIT).toInt()
val blockStart = findEmptySpace(allocBlocks) ?: throw OutOfMemoryError()