Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Deleting data from NSMutableData



On Mar 21, 2007, at 1:33 AM, Adam R. Maxwell wrote:

On Mar 20, 2007, at 22:25, Andy Lee wrote:

On Mar 21, 2007, at 12:04 AM, R. Tyler Ballance wrote:
I had thought about seeing what I could crash with using replaceBytesInRange:withBytes:length: and passing it a NULL, but that seems hackish and unstable at best.

I was going to suggest a combination of -mutableBytes, strncpy(), and -setLength, but this method sounds like exactly what you need. I haven't tested all boundary cases, but it seems to work. I don't see any reason not to use it.

Since NSMutableData is toll-free bridged with CFMutableData, why not use CFDataDeleteBytes()? That should always do the right thing.

Agreed.

If you want to use -replaceBytesInRange:withBytes:length: passing NULL for bytes and 0 for length you are safe at least on 10.4.8 since that is what CFDataDeleteBytes does:

http://www.opensource.apple.com/darwinsource/10.4.8.x86/CF-368.27/ Collections.subproj/CFData.c

If you want to be paranoid or conservative, you may want to continue using CFDataDeleteBytes until such time as the documentation sanctions NULL, 0 as a valid input for - replaceBytesInRange:withBytes:length:.

(DOC request filed as <rdar://problem/5077644>.)

Jim

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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/email@hidden

This email sent to email@hidden
References: 
 >Deleting data from NSMutableData (From: "R. Tyler Ballance" <email@hidden>)
 >Re: Deleting data from NSMutableData (From: Jim Correia <email@hidden>)
 >Re: Deleting data from NSMutableData (From: "R. Tyler Ballance" <email@hidden>)
 >Re: Deleting data from NSMutableData (From: Andy Lee <email@hidden>)
 >Re: Deleting data from NSMutableData (From: "Adam R. Maxwell" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.