Re: Memory leak if alloc succeeds but init fails?
Re: Memory leak if alloc succeeds but init fails?
- Subject: Re: Memory leak if alloc succeeds but init fails?
- From: Wincent Colaiuta <email@hidden>
- Date: Mon, 1 Oct 2007 16:23:20 +0200
El 1/10/2007, a las 1:36, Jeff Laing escribió:
Exceptions should really only be used to signal programmer errors;
that is failed assumptions (things you assume to be true).
So I would say, return nil if the failure to initialize is caused by
an external factor outside of your control, and raise an
exception if your assumptions about what state should be true have
not been met.
This is a subjective assessment, easily contradicted. I think the
failure
of alloc to return me any memory would be 'an external factor
outside of my
control', but would not have expected it to happen. Its definitely
something that I cannot 'pre-check'.
I totally agree with you. The success or otherwise of a memory
allocation is something outside of your control, something whose
success you should not "assume" and you should therefore check the
result. I never said otherwise.
Cheers,
Wincent
_______________________________________________
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