gnash-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnash-dev] Alignment in AMF data


From: strk
Subject: Re: [Gnash-dev] Alignment in AMF data
Date: Fri, 24 Oct 2008 10:34:15 +0200

On Fri, Oct 24, 2008 at 02:16:38AM -0400, Russ Nelson wrote:

> Unfortunately, fetching full-sized data from a buffer is subject to
> alignment problems.  Rob (our fearless leader) doesn't like the
> following code, but it never has byte sex or alignment problems, and
> there's never any ambiguity about exactly what you're loading.

In this case it's Jason Woof's code :)

>             double ddd;
>             uint8 *bbb = (uint8 *)el->getData();
>           ddd  = (bbb[0] << 24);
>           ddd |= (bbb[1] << 16);
>           ddd |= (bbb[2] <<  8);
>           ddd |= (bbb[3] <<  0);
> 
> I'm not sure that counting from 0 -> 3 is correct because I never know
> when to byteswap and when not to.  I've seen code (not in gnash) where
> the author was equally confused and didn't byte-swap when he had to.
> Perhaps it needs to be counting from 3 -> 0.  The only way to find out
> for sure is to look at the definition of the data stream.

And don't forget a double is 8 bytes, not 4...

--strk;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]