• 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: "Simson Garfinkel" <email@hidden>
  • Date: Sun, 17 Feb 2002 09:45:26 -0500

Hm. What' I'm looking for, I guess, is an NSData that lets me overlay a
block of data that is allocated and owned by another part of my program. I
want it only copied if necessary. I guess this behavior is simply not
available?
----- Original Message -----
From: "Lance Bland" <email@hidden>
To: "Simson Garfinkel" <email@hidden>
Cc: <email@hidden>
Sent: Saturday, February 16, 2002 6:43 PM
Subject: Re: NSMutableData doesn't support dataWithBytesNoCopy properly


>
> 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.

References: 
 >Re: NSMutableData doesn't support dataWithBytesNoCopy properly (From: Lance Bland <email@hidden>)

  • Prev by Date: Mailing list merger (Was: Re: Cursor zone)
  • Next by Date: Re: performZoom: in awakeFromNib
  • Previous by thread: Re: NSMutableData doesn't support dataWithBytesNoCopy properly
  • Next by thread: Re: NSMutableData doesn't support dataWithBytesNoCopy properly
  • Index(es):
    • Date
    • Thread