Re: NSData dataWithBytes:length:
Re: NSData dataWithBytes:length:
- Subject: Re: NSData dataWithBytes:length:
- From: Aaron Tuller <email@hidden>
- Date: Thu, 3 Jul 2003 11:51:47 -0700
You leak becayse you never free the bytes that you malloc.
dataWithBytes: copies the data into a new NSData object, you are
responsible for freeing the malloc-ed bytes, but not the NSData.
If you want to do what you're doing do a dataWithBytesNoCopy:length:
and then NSData will clean up for you when it's dealloc'd.
-aaron
At 2:03 PM -0400 7/3/03, Brent Gulanowski wrote:
// insert code here...
length = sizeof(char)*1000;
bytes = (char *)malloc(length);
data = [NSData dataWithBytes:bytes length:length];
NSLog(@"%@", data );
[pool release];
usleep( 10000 );
_______________________________________________
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.