issue #26: the reason was the dangling pointer?

This commit is contained in:
minjaesong
2019-06-23 02:20:01 +09:00
parent 601afc2636
commit 4e89a32e4e
4 changed files with 41 additions and 41 deletions

View File

@@ -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)
}
}