https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
h

hfhbd

07/05/2022, 4:51 PM
How do you create CPointer<UByteVarOf<UByte>>? I simple want to pass the value 0
r

russhwolf

07/05/2022, 7:27 PM
Copy code
memScoped { 
    val uByteVar = alloc<UByteVar>()
    val pointer = uByteVar.ptr
    pointer.pointed.value = 0u
    // do stuff with pointer here
}
// It's not safe to hold onto a reference to pointer here
h

hfhbd

07/05/2022, 8:21 PM
Thanks, what a overhead
l

Landry Norris

07/05/2022, 8:49 PM
Make sure to watch out for if you need an array as opposed to a pointer to a single value. If you need an array, you can use allocArray<UByteVar>(length) { 0 }
2 Views