kevin.cianfarini
09/28/2021, 6:06 PMmemScope
would work for this, but I’m unsurenapperley
09/29/2021, 12:36 AMkevin.cianfarini
09/29/2021, 2:14 PMclass KotlinNativeObject {
val myCinteropAllocation = AllocateSomeStruct()
}
// cinterop
void FreeSomeStruct(SomeStruct* stuct)
Ideally, I’d like to automatically free myCinteropAllocation
when its enclosing class gets garbage collected. That’s effectively a finalizer, though, and those are bad……
I’m wondering how other people have coped with this situation.napperley
09/29/2021, 9:58 PMinterface Closable {
fun close()
}
napperley
09/29/2021, 10:00 PMkevin.cianfarini
09/30/2021, 12:03 AM吴少滨
10/26/2021, 11:00 AMinterface Closable {
fun close()
}
when is the close function be called?kevin.cianfarini
11/19/2021, 3:41 PMuse
function.
fun Closeable.use(block: () -> Unit) {
try {
block()
} finally {
close()
}
}