Re: [dev] Introducing the imagefile-format
On Mon, Jul 28, 2014 at 6:55 PM, FRIGN <dev_AT_frign.de> wrote:
> fread(hdr, 1, 17, fd);
> width = ntohl((hdr[9] << 0) | (hdr[10] << 8) | (hdr[11] << 16) | (hdr[12] << 24));
> height = ntohl((hdr[13] << 0) | (hdr[14] << 8) | (hdr[15] << 16) | (hdr[16] << 24));
Isn't ntohl superfluous here? In fact, wouldn't this break on a big-endian
architecture? If I'm reading this right, we're storing the value in memory in
reverse (of native) byte order, assume it's now big-endian and convert it to
native byte order. Wouldn't this suffice?
width = (hdr[9] << 24) | (hdr[10] << 16) | (hdr[11] << 8) | hdr[12]
height = (hdr[13] << 24) | (hdr[14] << 16) | (hdr[15] << 8) | hdr[16]
Received on Tue Jul 29 2014 - 01:37:30 CEST
This archive was generated by hypermail 2.3.0
: Tue Jul 29 2014 - 01:48:06 CEST