On Mon, Jul 28, 2014 at 6:55 PM, FRIGN <d...@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]