RE: Strangeness when moving data through an array.
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