mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-15 16:16:10 +09:00
issue #26: the reason was the dangling pointer?
This commit is contained in:
@@ -37,10 +37,10 @@ class UnsafePtr(val ptr: Long, val allocSize: Long) {
|
||||
}
|
||||
|
||||
private inline fun checkNullPtr(index: Long) {
|
||||
if (destroyed) throw NullPointerException()
|
||||
if (destroyed) throw NullPointerException("The pointer is already destroyed (0x${ptr.toString(16)})")
|
||||
|
||||
// OOB Check: debugging purposes only -- comment out for the production
|
||||
//if (index !in 0 until allocSize) throw NullPointerException("Out of bounds: $index; alloc size: $allocSize")
|
||||
//if (index !in 0 until allocSize) throw IndexOutOfBoundsException("Index: $index; alloc size: $allocSize")
|
||||
}
|
||||
|
||||
operator fun get(index: Long): Byte {
|
||||
@@ -63,4 +63,8 @@ class UnsafePtr(val ptr: Long, val allocSize: Long) {
|
||||
UnsafeHelper.unsafe.putFloat(ptr + index, value)
|
||||
}
|
||||
|
||||
fun fillWith(byte: Byte) {
|
||||
UnsafeHelper.unsafe.setMemory(ptr, allocSize, byte)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user