• 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: NSData dataWithBytes:length:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSData dataWithBytes:length:
      • From: Brent Gulanowski <email@hidden>
References: 
 >NSData dataWithBytes:length: (From: Brent Gulanowski <email@hidden>)

  • Prev by Date: Re: Obj-C language question: C function within @implementation
  • Next by Date: Re: NSData dataWithBytes:length:
  • Previous by thread: NSData dataWithBytes:length:
  • Next by thread: Re: NSData dataWithBytes:length:
  • Index(es):
    • Date
    • Thread