Allow nullable ReferenceCounted objects to be passed to use

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent 3289af5ddf
commit c295ecb0a0
  1. 4
      buffer/src/main/kotlin/org/openrs2/buffer/ReferenceCountedExtensions.kt

@ -2,10 +2,10 @@ package org.openrs2.buffer
import io.netty.util.ReferenceCounted
public inline fun <T : ReferenceCounted, R> T.use(block: (T) -> R): R {
public inline fun <T : ReferenceCounted?, R> T.use(block: (T) -> R): R {
try {
return block(this)
} finally {
release()
this?.release()
}
}

Loading…
Cancel
Save