Juan Lang juan_lang@yahoo.com writes:
void StorageUtl_ReadWord(const BYTE* buffer, ULONG offset, WORD* value) {
- memcpy(value, buffer+offset, sizeof(WORD));
- *value = le16toh(*(WORD *)(buffer+offset));
}
Why are you removing the memcpy? Are the offsets guaranteed to always be properly aligned?
+#ifdef WORDS_BIGENDIAN
+/* FIXME: more-optimal versions may be in <byteswap.h>, <sys/bswap.h>, or
- <sys/endian.h>. Use config checks to find 'em.
No, you don't want config checks, what you want to use here is RtlUshortByteSwap/RtlUlongByteSwap.