Memory leak if alloc succeeds but init fails?
Memory leak if alloc succeeds but init fails?
- Subject: Memory leak if alloc succeeds but init fails?
- From: "R.L. Grigg" <email@hidden>
- Date: Thu, 27 Sep 2007 22:10:55 -0700
Apple's Cocoa Memory Management Programming guide shows this pattern
for init:
- (id)init {
if ((self = [super init])) {// superclass may return nil
// your initialization code goes here
}
return self;
}
Newb question: In the case of
id myObject = [[MyObject alloc]init];
what happens to the allocated memory if the [super init] fails and
how do I handle it since I dont have a self to release?
Thx
Russ
_______________________________________________
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