[Zlib-devel] Byte-swapping cleanup

Mark Adler madler at madler.net
Sat Feb 11 03:06:21 EST 2012


Steve,

Thanks.  I may apply some of the patch to make use of the optimized swaps.

Note that changes like:

-        hbuf[0] = (unsigned char)(word); \
-        hbuf[1] = (unsigned char)((word) >> 8); \
+        *((unsigned short *)&hbuf[0]) = ZSWAP16(word & 0xffff); \

are wrong.  Such a change assumes an endianess of the processor (in particular big endian), whereas the original code does not.

Mark





More information about the Zlib-devel mailing list