Re: sigbus error 10 (newbie)
Re: sigbus error 10 (newbie)
- Subject: Re: sigbus error 10 (newbie)
- From: Matt Neuburg <email@hidden>
- Date: Fri, 18 Mar 2005 19:05:45 -0800
On Fri, 18 Mar 2005 15:58:35 -1000, Daniel Child <email@hidden> said:
>- (NSMutableSet *)strokeTypesHavingDescription:(NSString *)d
>{
> int i = 0;
> NSMutableSet *matchingTypes = [[NSMutableSet alloc] init];
> NSString *thisDesc = [[NSString alloc] init];
> NSNumber *thisType = [[NSString alloc] init];
Error. You cannot assign a string to a number (thisType).
>
> for (i = 0; i < numInList; i++)
> // Note: numInList is a member variable that counts knownStrokes
> {
> thisDesc = [[knownStrokes objectAtIndex: i] desc];
> thisType = [[knownStrokes objectAtIndex: i] strokeType];
First you create a new empty string and a new empty number (thisDesc and
thisType) with alloc/init. Then you wantonly throw away that new empty
string and new empty number and replace them with references to existing
objects in an array. So no pointer now points to the empty string and number
you created earlier - they can never be released because nothing points to
them - that's a leak.
> // [thisDesc release];
> // [thisType release];
That would be a crash. At this point, thisDesc and thisType are merely
pointers to objects in an array. You do not own them - the array does - and
it is not your business to release them. (It *would* be your business to
release the empty string/number you created earlier, but you can't because
you have no pointer to them.)
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden