On Jul 16, 2009, at 1:37 PM, Kyle Sluder wrote:

This makes many people's lives difficult.  It's kinda bogus that if I
pass in the address of a pointer-to-NULL and receive back a YES that I
have to turn around and re-NULL that pointer before reusing it.  Many
AppKit methods have a tendency to set the *error argument to 0x8 when
they return YES, causing havoc with our error-wrapping macros.

Then your macros are buggy.

Given:

NSError *foo;
result = [moc save: &foo];

(1) if the result is NO, the value of foo is undefined.

(2) If result is YES, foo *must* be set to a valid NSError

(3) -save: *must not* assume anything about foo; must not treat it is a valid pointer to anything.

Setting foo to NULL before the call is a wasted instruction. Checking foo for NULL after the call doesn't make sense since you have to test result to know if foo was set.

For completeness, the above is distinct from [moc save: NULL]; -save: does check for a NULL and the common optimization is to not create an NSError at all.

b.bum





_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to