Re: writing huge C-array to a file
Re: writing huge C-array to a file
- Subject: Re: writing huge C-array to a file
- From: Greg Hoover <email@hidden>
- Date: Fri, 15 Sep 2006 12:23:29 -0700
I'm writing a large C-array to file using an NSFileHandle and am
encapsulating the array in an NSData object. As I understand it, you
have 2 options: (1) copy all the data in your array into an NSData
object with new memory allocations (using initWithBytes) or (2)
create an NSData object using initWithBytesNoCopy which doesn't have
the overhead of copying the data new a new memory allocation. I'd
like to avoid having to copy the data around unnecessarily, but using
initWithBytesNoCopy is problematic because the new NSData object
takes ownership of memory associated with the C-array, which means
that it is deallocated with the NSData object. Since the NSData
object is only used temporarily for file writing, the data that I'd
like to keep around ends up being deallocated.
Is there a way to retain data from an NSData object such that when it
is deallocated, it's data memory is not? Is there a more appropriate
way to write the data to file?
Thank you.
Greg
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden