kevin.cianfarini
12/27/2022, 4:07 PMgetPointer
on a cstr. For context, I need to pass a pointer to String to a C function and have that memory be valid after the current function call pops off the stack.
To do that, the cinterop guide mentions allocating the c string in native memory using
val cstring = "some string".cstr.getPointer(nativeHeap)
This produces a pointer to valid memory. However, why does this function any differently than
val pinnedCstr = "some string".cstr.pin()
I want to manually unpin this value and avoid the copy if I can. This memory is no longer valid once it's accessed from the C library I'm interfacing with and I don't understand why