Re: [OT] Retain count riddle
Re: [OT] Retain count riddle
- Subject: Re: [OT] Retain count riddle
- From: Andreas Mayer <email@hidden>
- Date: Tue, 30 Mar 2004 22:24:35 +0200
Am 30.03.2004 um 21:49 schrieb Sailesh Agrawal:
Can anyone guess what the problem is ?
Sure. [path lastPathComponent] is called twice and the object from the
first call is different from the object from the second call.
[[path lastPathComponent] retain]; [m_Path release]; m_Path = [path
lastPathComponent];
This is equivalent to:
NSString *a = [path lastPathComponent];
NSString *b = [path lastPathComponent];
[a retain]; [m_Path release]; m_Path = b;
So you end up with a memory leak (a) and a crash (b). :)
Andreas
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.