How do you create CPointer<UByteVarOf<UByte&...
# kotlin-native
h
How do you create CPointer<UByteVarOf<UByte>>? I simple want to pass the value 0
r
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
Thanks, what a overhead
l
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 }