Hey, I am working with C Interoperability and tryi...
# multiplatform
j
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
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
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.