sigbus on rangeOfString:
sigbus on rangeOfString:
- Subject: sigbus on rangeOfString:
- From: Darin Duphorne <email@hidden>
- Date: Wed, 27 Feb 2002 00:02:10 -0600
Why does the following work, but when I replace range=[string
rangeOfString:@"\n"]; with range=[string
rangeOfString:@"test.\n"]; I get a sigbus and *** malloc[2832]: error:
Can't allocate region?
NSMutableString *string;
NSMutableString *result;
NSRange range;
string=[[NSMutableString alloc] initWithString:@" This is a test.\n
This is only a test.\n"];
result=[[NSMutableString alloc] init];
while ([string length]>0)
{
range=[string rangeOfString:@"\n"];
[result appendString:[string substringToIndex:range.location]];
[result appendString:@"crlf"];
[string setString:[string substringFromIndex:(range.location+1)]];
}
_______________________________________________
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.