• 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: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare


  • Subject: Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
  • From: Jeremy Pereira <email@hidden>
  • Date: Tue, 27 Jan 2009 15:24:30 +0000


On 27 Jan 2009, at 14:23, Adam Venturella wrote:


 Leopard is little endian ( at least on
the intel chips, but I have read there are other macs that are
big-endian, so I am trying to catch and handle that accordingly)

The endianness is dependent on the processor architecture, not the operating system. Intel Macs are little endian, but PowerPC Macs are big endian no matter which OS is running on them.





With regard to how the casting is actually working, I just want to make sure I understand the logic:

uint key = *(uint*)&buffer;

from right to left this is what is happening:
Get a pointer/reference to 'buffer'.  Cast that pointer into a uint
pointer.  Then, dereference the pointer to get it's value.

Is that correct?

Yes. That is correct, but since buffer is already a pointer to the first byte of the array and then you are taking a reference to it, key will end up containing the address of the buffer. You really need:


uint key = *(uint*)buffer;



_______________________________________________

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: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
      • From: Graham Cox <email@hidden>
    • Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
      • From: Steve Christensen <email@hidden>
    • Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
      • From: "Sean McBride" <email@hidden>
References: 
 >Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare (From: William Jon Shipley <email@hidden>)
 >Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare (From: Adam Venturella <email@hidden>)

  • Prev by Date: IntefaceBuilder IPhone TableView Size Question
  • Next by Date: Re: Context Menu in NSBrowser
  • Previous by thread: Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
  • Next by thread: Re: Is there a more efficient way to get the first 4 bytes off a NSInputStream to compare
  • Index(es):
    • Date
    • Thread