• 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: Strangeness when moving data through an array.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Strangeness when moving data through an array.


  • Subject: RE: Strangeness when moving data through an array.
  • From: Jeff Laing <email@hidden>
  • Date: Wed, 1 Dec 2004 22:13:15 +1100

> But I don't think that's what John wants to do - I think he wants to
> assign the two bytes pkt[MSEQ] and pkt[MSEQ+1] to a u_short.
> To do that
> with a direct assignment, you'd need to take the address of the array
> element you want, typecast that pointer to a u_short*, and then
> dereference it:
>
> short_test = *((u_short*)&pkt[MSEQ]);
>
> That's a *little* simpler than the function call, but not a
> whole heck
> of a lot.

Not on architectures that care about word-alignment you don't.

If pkt[MSEQ] is not on a 16-bit boundary, you'll get an exception.

No idea whether OSX actually handles it for you, but its bad mojo thats best
stayed away from, especially in code that you want to run fast.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Strangeness when moving data through an array.
      • From: Sherm Pendley <email@hidden>
  • Prev by Date: Re: NSFileManager fun & games
  • Next by Date: RE: Swapping isa's (was Re: Hex Edit controls (resknife))
  • Previous by thread: Re: Strangeness when moving data through an array.
  • Next by thread: Re: Strangeness when moving data through an array.
  • Index(es):
    • Date
    • Thread