Matthieu Stombellini
02/22/2021, 1:27 PMval result: CValue<Thing> = my_c_function_call()
val resultButRealThisTime: Thing = ???
Doing
val result = my_c_function_call()
val resultButReal: Thing? = null
result.useContents { resultButReal = this@useContents }
Works, but looks awful and I don't think that's how you're supposed to do thatrusshwolf
02/22/2021, 1:40 PMval resultButReal: Thing = result.useContents { this }
Matthieu Stombellini
02/22/2021, 2:00 PMMatthieu Stombellini
02/22/2021, 2:44 PMrusshwolf
02/22/2021, 4:07 PMmkrussel
02/22/2021, 5:15 PMuseContents
method. If you need to be storing it for later use, store it as a CValue.Dominaezzz
02/22/2021, 9:15 PMThing
a struct? If so, you'll have to allocate with nativeHeap
to do what you want here.
Although it's best to leave it inside useContents
if you can so garbage collection still works.