---
title: "CFMachPortCreate(_:_:_:_:)"
framework: corefoundation
role: symbol
role_heading: Function
path: "corefoundation/cfmachportcreate(_:_:_:_:)"
---

# CFMachPortCreate(_:_:_:_:)

Creates a CFMachPort object with a new Mach port.

## Declaration

```swift
func CFMachPortCreate(_ allocator: CFAllocator!, _ callout: CFMachPortCallBack!, _ context: UnsafeMutablePointer<CFMachPortContext>!, _ shouldFreeInfo: UnsafeMutablePointer<DarwinBoolean>!) -> CFMachPort!
```

## Parameters

- `allocator`: The allocator to use to allocate memory for the new object. Pass NULL or doc://com.apple.corefoundation/documentation/CoreFoundation/kCFAllocatorDefault to use the current default allocator.
- `callout`: The callback function invoked when a message is received on the new Mach port.
- `context`: A structure holding contextual information for the new Mach port. The function copies the information out of the structure, so the memory pointed to by context does not need to persist beyond the function call.
- `shouldFreeInfo`: A flag set by the function to indicate whether the info member of context should be freed. The flag is set to true on failure, false otherwise. shouldFreeInfo can be NULL.

## Return Value

Return Value The new CFMachPort object or NULL on failure. The CFMachPort object has both send and receive rights. Ownership follows the The Create Rule.

## See Also

### Creating a CFMachPort Object

- [CFMachPortCreateWithPort(_:_:_:_:_:)](corefoundation/cfmachportcreatewithport(_:_:_:_:_:).md)
