• 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
NSData release seg fault. Whoops.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSData release seg fault. Whoops.


  • Subject: NSData release seg fault. Whoops.
  • From: nik heger <email@hidden>
  • Date: Tue, 20 Jan 2009 11:39:36 +0700

I figured out how to make this code "work" but I still don't know what the problem was. Can someone enlighten me?

- (void)testSegFault {
int size = 8;
uint8_t *bytes = malloc( size * sizeof(uint8_t) );
NSData *data = [NSData dataWithBytesNoCopy:bytes length:size];
[data release];// this causes a seg fault.... comment it out and everything works.
}


According to the NSData documentation, the NSData object will take ownership of the array I created with malloc. So far so good but why don't I have to release it? Or is there something sinister going on with the uint8_t data type vs. size of the byte(?) array?

thanks,

	Nik
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSData release seg fault. Whoops.
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: NSView behaves different on 10.4 vs 10.5?
  • Next by Date: Re: real noob question
  • Previous by thread: Re: NsCollectionView Selection
  • Next by thread: Re: NSData release seg fault. Whoops.
  • Index(es):
    • Date
    • Thread