• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSMutableData doesn't support dataWithBytesNoCopy properly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSMutableData doesn't support dataWithBytesNoCopy properly
      • From: "Simson Garfinkel" <email@hidden>
References: 
 >NSMutableData doesn't support dataWithBytesNoCopy properly (From: Simson Garfinkel <email@hidden>)

  • Prev by Date: NSMutableData doesn't support dataWithBytesNoCopy properly
  • Next by Date: Re: NSMutableData doesn't support dataWithBytesNoCopy properly
  • Previous by thread: NSMutableData doesn't support dataWithBytesNoCopy properly
  • Next by thread: Re: NSMutableData doesn't support dataWithBytesNoCopy properly
  • Index(es):
    • Date
    • Thread