@@ -92,11 +92,13 @@ public struct DispatchData : RandomAccessCollection {
9292 public func enumerateBytes(
9393 block: ( _ buffer: UnsafeBufferPointer < UInt8 > , _ byteIndex: Int , _ stop: inout Bool ) -> Void )
9494 {
95- _swift_dispatch_data_apply ( __wrapped. __wrapped) { ( data: dispatch_data_t , offset: Int , ptr: UnsafeRawPointer , size: Int ) in
95+ // FIXME: When SR-2313 (withoutActuallyEscaping) is implemented, use it to replace unsafeBitCast
96+ let nonEscapingBlock = unsafeBitCast ( block, to: _enumerateBytesBlock. self)
97+ _ = CDispatch . dispatch_data_apply ( __wrapped. __wrapped) { ( _, offset: Int , ptr: UnsafeRawPointer , size: Int ) in
9698 let bytePtr = ptr. bindMemory ( to: UInt8 . self, capacity: size)
9799 let bp = UnsafeBufferPointer ( start: bytePtr, count: size)
98100 var stop = false
99- block ( bp, offset, & stop)
101+ nonEscapingBlock ( bp, offset, & stop)
100102 return !stop
101103 }
102104 }
@@ -275,10 +277,7 @@ public struct DispatchDataIterator : IteratorProtocol, Sequence {
275277 internal var _position : DispatchData . Index
276278}
277279
278- typealias _swift_data_applier = @convention ( block) ( dispatch_data_t , Int , UnsafeRawPointer , Int ) -> Bool
279-
280- @_silgen_name ( " _swift_dispatch_data_apply " )
281- internal func _swift_dispatch_data_apply( _ data: dispatch_data_t , _ block: _swift_data_applier )
280+ typealias _enumerateBytesBlock = ( _ buffer: UnsafeBufferPointer < UInt8 > , _ byteIndex: Int , _ stop: inout Bool ) -> Void
282281
283282@_silgen_name ( " _swift_dispatch_data_empty " )
284283internal func _swift_dispatch_data_empty( ) -> dispatch_data_t
0 commit comments