https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
j

Jakub Sieprawski

03/06/2023, 5:32 PM
Hey, I am working with C Interoperability and trying to obtain all array objects from OpaquePointer. Firstly I am allocating COpaquePointerVar, then I am assigning to its value, value of allocated certificates array. Then I am trying to obtain all list elements. Getting first SecCertificateRef works fine but when I am trying to obtain second one its equality fails also when I am trying to cast it to SecCertificateRef I am getting memory access error so my question is what am I doing wrong here? I will appreciate any help
j

Jeff Lockhart

03/06/2023, 6:07 PM
opaqueRef
is only getting the value of
certCArray[0]
when you set it with
opaqueRef.value = certCArray.pointed.value
.
opaqueRef[1]
isn't memory that you allocated, as you only allocated a single
COpaquePointerVar
and not an array as you did for
certCArray
.
l

Landry Norris

03/06/2023, 6:22 PM
Don't cast for C types. Use the generic reinterpret method on CPointer
You can even simplify this opaqueRef as certCArray.reinterpret<CPointed>() unless you need a copy.
7 Views