Hi, why does `platform.darwin.DISPATCH_DATA_DESTRU...
# kotlin-native
t
Hi, why does
platform.darwin.DISPATCH_DATA_DESTRUCTOR_DEFAULT
not appear as a
dispatch_block_t
? Just like
DISPATCH_DATA_DESTRUCTOR_FREE
, which does appear to be correct. Instead of
dispatch_block_t
it appears as
kotlinx.cinterop.COpaquePointer?
. I have no idea how I can use that as a dispatch block.
message has been deleted
o
it has value of
NULL
, thus isn’t valid function pointer
t
@olonho so that means I can not use it? Should I just use null instead? I want to use it as the last parameter in this function: https://developer.apple.com/documentation/dispatch/1452970-dispatch_data_create?language=objc
I’m currently using this:
Copy code
private fun ByteArray.toDispatchData(): dispatch_data_t = usePinned { pinned ->
    dispatch_data_create(
        buffer = pinned.addressOf(0),
        size = size.convert(),
        queue = dispatch_get_main_queue(),
        destructor =  TODO()
    )
}
So can I just use null for the destructor? Or would that cause memory leaks?
I think I need to use
DISPATCH_DATA_DESTRUCTOR_DEFAULT
because the docs say:
If you specify the default destructor using the DISPATCH_DATA_DESTRUCTOR_DEFAULT constant, this function creates a copy of the data in buffer and manages that data internally.
o
Null shall be fine, if it compiles.
t
Ok thanks. Appreciate the help!