Re: "Ownership follows the 'Create' Rule'" - not literally
Re: "Ownership follows the 'Create' Rule'" - not literally
- Subject: Re: "Ownership follows the 'Create' Rule'" - not literally
- From: "Stephen J. Butler" <email@hidden>
- Date: Sun, 25 Aug 2013 04:14:27 -0500
What they're saying here is that that parameter is following the "Create
Rule" even though the function doesn't have a normal name for following the
rule. They are documenting an exception to the ownership rule.
If the function name did follow the rule it would be redundant to document
it as such. The documentation is there to tell you this function doesn't
follow the ownership rule its name suggests, but rather the Create Rule.
On Fri, Aug 23, 2013 at 11:13 PM, Jerry Krinock <email@hidden> wrote:
> OS X app, manual retain/release.
>
> According to 'leaks' with MallocStackLoggingNoCompact, I was leaking a
> CFData object when I called CFMessagePortSendRequest().
>
> Indeed, the last parameter of CFMessagePortSendRequest() returns a CFData
> object by reference, and the documentation states that "Ownership follows
> the 'Create Rule'" for this parameter. When I wrote this code, I read the
> Create Rule, looked at the name "CFMessagePortSendRequest", did not see the
> word "Create" or "Copy" and so said, "that CFData is not mine to release".
>
> Now, faced with the leak, I added a -release when I was done with that
> CFData, and tested with MallocScribble and MallocPreScribble environment
> variables set to 1. Result: No more leak, no crashes.
>
> Lesson: When documentation says that "Ownership follows the 'Create Rule'"
> for a parameter, what they really mean to say is that "When applying the
> 'Create Rule' to this function, proceed as though this function had
> 'Create' in its name". Or, more succinctly, "You own this object".
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden