CFMachPortCreateWithPort performs a copy

For reasons I have not yet attempted to determine, CFMachPortCreateWithPort is backed by a cache whose key is the mach_port_t which the client provides. The function first searches this cache for previously created instances of CFMachPortRef with the specified mach_port_t. If one is present, the function passes the CFMachPortRef to CFRetain and returns it. A Create function thus returns a copy despite its name. If no matching CFMachPortRef is present in the cache, CFMachPortCreateWithPort creates one and adds it to the cache before returning it.

No comments: