[cfe-dev] Static analyser and objc init methods
shawnce at gmail.com
Thu Oct 30 08:43:39 PDT 2008
On Wed, Oct 29, 2008 at 3:37 PM, Jean-Daniel Dupas
<devlists at shadowlab.org> wrote:
> I think the memory leak analyser need a special semantic for objc
> class initializer methods.
> Generaly, an initializer returns self, but in some case, it may decide
> to return something else (or throw an exception)
> In these cases, 'self' must be release before the method returns else
> it will leaks. (http://www.cocoabuilder.com/archive/message/cocoa/2008/2/11/198549
> Additionaly, if an init method returns a new object, this object
> should be returns with a retain count to 1.
I don't think that is a correct requirement, at least not directly as stated.
It could be an application life long object with a possibly a MAX_INT
retain count. It could be an object with a retain count greater then 1
but with deferred releases (added to the current autorelease pool one
or more times).
More information about the cfe-dev