- let d = dispatch_data_create(bytes.baseAddress!, bytes.count, q?.__wrapped, b)
+ let d = bytes.baseAddress == nil ? _swift_dispatch_data_empty()
+ : dispatch_data_create(bytes.baseAddress!, bytes.count, q?.__wrapped, b)
+ self.init(data: d)
+ }
+
+ /// Initialize a `Data` without copying the bytes.
+ ///
+ /// - parameter bytes: A pointer to the bytes.
+ /// - parameter count: The size of the bytes.
+ /// - parameter deallocator: Specifies the mechanism to free the indicated buffer.
+ public init(bytesNoCopy bytes: UnsafeRawBufferPointer, deallocator: Deallocator = .free) {
+ let (q, b) = deallocator._deallocator
+ let d = bytes.baseAddress == nil ? _swift_dispatch_data_empty()
+ : dispatch_data_create(bytes.baseAddress!, bytes.count, q?.__wrapped, b)