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 21:26:55 +0200

On Fri, Oct 24, 2008 at 01:22:18PM -0600, Rob Savoye wrote:
> strk wrote:
> > On Fri, Oct 24, 2008 at 12:00:16PM -0700, Bastiaan Jacques wrote:
> 
> > As far as I can see amf0_read_valu already uses specialized functions
> > to read shorts and longs (readNetworkShort, readNetworkLong).
> 
>   These should be changed to use the the standard ntohs() and ntohl(),
> or swapBytes() to be more consistent.

readNetworkShort and readNetworkLong use bitshifting, so single copy and
byte order agnostic:

 static boost::uint16_t
 readNetworkShort(const boost::uint8_t* buf) {
     boost::uint16_t s = buf[0] << 8 | buf[1];
     return s;
 }

 static boost::uint32_t
 readNetworkLong(const boost::uint8_t* buf) {
     boost::uint32_t s = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
     return s;
 }


Maybe we really want a readNetworkDouble ...

--strk;




reply via email to

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