Re: NSMutableData doesn't support dataWithBytesNoCopy properly
Re: NSMutableData doesn't support dataWithBytesNoCopy properly
- Subject: Re: NSMutableData doesn't support dataWithBytesNoCopy properly
- From: Lance Bland <email@hidden>
- Date: Sat, 16 Feb 2002 18:43:56 -0500
On Saturday, February 16, 2002, at 02:37 PM, Simson Garfinkel wrote:
*** malloc[2580]: Deallocation of a pointer not malloced: 0x1ee0; This
could be a double free(), or free() called with the middle of an
allocated block; Try setting environment variable MallocHelp to see
tools to help debug
NSData's (and conforming subclasses) methods with NoCopy frees the bytes
when the instance is freed. You have to pass a malloc'd byte section
bytes = malloc(5);
strncpy(bytes, "abcde", 5);
data = [NSMutableData dataWithBytesNoCopy:bytes length:5];
[data release]; // calls free(bytes) so no leak
I would like NSMutableData to support dataWithBytesNoCopy properly, but
I also want it to handle append properly. Has anybody else other
encountered this?
[data appendData:]
[data appendBytes:length:]
-lance
_______________________________________________
Lance Bland
System Administrator at VVI
mailto:email@hidden
http://www.vvi.com
Realtime, bulk and web data reporting and visualization
_______________________________________________
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.