Closed MaddTheSane closed 1 day ago
I'd recommend implement additional cf_ReadShortBE() and cf_ReadIntBE() or extend current cf_ReadShort() and cf_ReadInt() with optional parameter little_endian
in CFILE module like this:
// Declaration in cfile.h
int32_t cf_ReadInt(CFILE *cfp, bool little_endian = true);
// Implementation in cfile.cpp
int32_t cf_ReadInt(CFILE *cfp, bool little_endian) {
int32_t i;
cf_ReadBytes((uint8_t *)&i, sizeof(i), cfp);
return (little_endian ? INTEL_INT(i) : MOTOROLA_INT(i));
}
After that you can use it without additional conversion code in iff
Pull Request Type
Description
There were a couple of places that weren't byte-swapped on little-endian systems. And due to
cf_ReadInt
andcf_ReadShort
automatically callingINTEL_INT
which then byte-swaps the value on big-endian machines, the next calls toMOTOROLA_SHORT
andMOTOROLA_INT
don't swap the value because it's on a big-endian machine.Checklist
Additional Comments