@@ -90,7 +90,7 @@ extension mach_msg_port_descriptor_t: Mach.MessageDescriptor {
9090 }
9191
9292 /// Creates a new port descriptor.
93- public init ( _ port: Mach . Port , disposition: Mach . PortDisposition ) {
93+ public init ( port: Mach . Port , disposition: Mach . PortDisposition ) {
9494 self . init (
9595 name: port. name,
9696 pad1: 0 , pad2: 0 ,
@@ -137,7 +137,7 @@ extension mach_msg_guarded_port_descriptor_t: Mach.MessageDescriptor {
137137
138138 /// Creates a new port descriptor.
139139 public init (
140- _ port: Mach . Port , disposition: Mach . PortDisposition , context: mach_port_context_t = 0 ,
140+ port: Mach . Port , disposition: Mach . PortDisposition , context: mach_port_context_t = 0 ,
141141 guardFlags: Mach . MessagePortGuardFlags = [ ]
142142 ) {
143143 self . init (
@@ -209,16 +209,27 @@ extension mach_msg_ool_descriptor_t: Mach.MessageDescriptor {
209209
210210 /// Creates a new OOL descriptor.
211211 public init (
212- _ data: Data , copyOption: Mach . OOLDescriptorCopyOption = . virtual,
212+ data: Data ? , copyOption: Mach . OOLDescriptorCopyOption = . virtual,
213213 deallocateOnSend: Bool = false
214214 ) {
215+ guard let actualData = data else {
216+ self . init (
217+ address: nil ,
218+ deallocate: deallocateOnSend ? 1 : 0 ,
219+ copy: copyOption. rawValue,
220+ pad1: 0 ,
221+ type: Mach . MessageDescriptorType. ool. rawValue,
222+ size: 0
223+ )
224+ return
225+ }
215226 self . init (
216- address: UnsafeMutableRawPointer ( mutating: ( data as NSData ) . bytes) ,
227+ address: UnsafeMutableRawPointer ( mutating: ( actualData as NSData ) . bytes) ,
217228 deallocate: deallocateOnSend ? 1 : 0 ,
218229 copy: copyOption. rawValue,
219230 pad1: 0 ,
220231 type: Mach . MessageDescriptorType. ool. rawValue,
221- size: mach_msg_size_t ( data . count)
232+ size: mach_msg_size_t ( actualData . count)
222233 )
223234 }
224235}
@@ -266,7 +277,7 @@ extension mach_msg_ool_ports_descriptor_t: Mach.MessageDescriptor {
266277
267278 /// Creates a new OOL ports descriptor.
268279 public init (
269- _ ports: [ Mach . Port ] , disposition: Mach . PortDisposition ,
280+ ports: [ Mach . Port ] , disposition: Mach . PortDisposition ,
270281 copyMethod: Mach . OOLDescriptorCopyOption ,
271282 deallocateOnSend: Bool = false
272283 ) {
0 commit comments