• 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
NSMutableData capacity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSMutableData capacity


  • Subject: NSMutableData capacity
  • From: Andreas Grosam <email@hidden>
  • Date: Wed, 23 May 2012 17:26:50 +0200

Is there an easy way to figure out the capacity of a NSMutableData object - that is the number of bytes that can be written to the data object without causing it to reallocate the internal buffer or invalidating the base pointer to the internal buffer?

Example:

NSMutableData* data  =  ..

[data increaseLengthBy:1234];
void * p = [data mutableBytes];
NSUInteger data_capacity = [data capacity];  // An API like this would be fine!
[data setLength: data_capacity];
assert(p == [data mutableBytes]);


That would be a "nice to have" feature. I wouldn't use an approach that requires tricky hacks into the allocator.


Any ideas?



Regards
Andreas
_______________________________________________

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: NSMutableData capacity
      • From: Jason Teagle <email@hidden>
    • Re: NSMutableData capacity
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: PDFThumbnailView Problem (kind of)
  • Next by Date: Re: NSDocument autosave doesn't show as edited
  • Previous by thread: Re: group row custom drawing nstableview
  • Next by thread: Re: NSMutableData capacity
  • Index(es):
    • Date
    • Thread