On Oct 8, 2011, at 14:31 , silve...@wfmh.org.pl wrote:

> What am I doing wrong? Shouldn't the instance created using 
> dataWithBytesNoCopy:length:freeWhenDone simply hold the same bytes as 
> the originally provided ones? 

Presumably you're using 'dataWithBytesNoCopy:length:freeWhenDone:NO', since 
'dataWithBytesNoCopy:length:freeWhenDone:YES' would be invalid in the scenario 
you describe. 

I'd guess that, with the 'NO' parameter, NSMutableData copies the data anyway. 
Mutating the data would become treacherous if the underlying memory doesn't 
belong to the NSMutableData object that's trying to mutate it.

So, really all you could do is change individual bytes, and you scarcely need 
subsidiary NSMutableData objects for that -- simple C pointers would do. (Note, 
however, that you'd be using interior pointers, which would open you up to a 
range of possible memory management issues, depending on which memory model 
you're using.)

What are you trying to get the subsidiary NSMutableData objects to do for you 
that C pointers won't?


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to