• 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
Re: Variables of N bits in size
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Variables of N bits in size


  • Subject: Re: Variables of N bits in size
  • From: Vince DeMarco <email@hidden>
  • Date: Fri, 25 May 2001 09:11:26 -0700

On Thursday, May 24, 2001, at 01:13 PM, Nat! wrote:

Am Donnerstag, 24. Mai 2001 um 18:13 schrieb Ken Tabb:

Hi,
what's the most Obj-C friendly way of defining object sizes in bits, for
instance if I want MyObject instances to be 1 bit long? Are ANSI C
bit-field concepts wrapped in C structs still the preferred method in
Obj-C or is there a 'better' way?

Thanks in advance,
Ken


Hi Ken

1 bit long object instances do not make much sense in Obj-C, because every Obj-C instance has an 32 bit isa pointer prepended. For malloc alignment and malloc overhead (size, next block etc) that would translate into probably about 16 bytes per instance [due to memory alignment you could get an int sized object as well...]

For bitsize instance variables (lots of them then), you use regular C- bitfields.

If you want to optimize for size, because you are allocating lots of them bits (like millions), you could write a wrapper class to handle those bits and deal with the individual bits through that, which gives you a small memory footprint and slightly better OO design.

If you really want to do this just use CFBitVector which wraps this just fine. Unless you really want to write you own code to do a bitVector.

vince


References: 
 >Re: Variables of N bits in size (From: Nat! <email@hidden>)

  • Prev by Date: Re: Type/Creator Codes
  • Next by Date: Another strange thing, this time on retainCount
  • Previous by thread: Re: Variables of N bits in size
  • Next by thread: Zombies from security framework
  • Index(es):
    • Date
    • Thread