diff --git a/src/core/global/qendian.h b/src/core/global/qendian.h index 0149c024b..0abf4456f 100644 --- a/src/core/global/qendian.h +++ b/src/core/global/qendian.h @@ -24,8 +24,6 @@ #include -#include - QT_BEGIN_NAMESPACE /* @@ -36,6 +34,11 @@ inline void qbswap_helper(const uchar *src, uchar *dest, int size) for (int i = 0; i < size ; ++i) dest[i] = src[size - 1 - i]; } +inline void qbcopy_helper(const uchar *src, uchar *dest, int size) +{ + for (int i = 0; i < size ; ++i) dest[i] = src[i]; +} + /* * qbswap(const T src, const uchar *dest); * Changes the byte order of \a src from big endian to little endian or vice versa @@ -188,7 +191,7 @@ template inline T qToLittleEndian(const T source) template inline T qFromLittleEndian(const T source) { return qbswap(source); } template inline void qToBigEndian(const T src, uchar *dest) -{ ::memcpy(dest, &src, sizeof(T)); } +{ qbcopy_helper(reinterpret_cast(&src), dest, sizeof(T)); } template inline void qToLittleEndian(const T src, uchar *dest) { qbswap(src, dest); } #else // Q_LITTLE_ENDIAN @@ -204,7 +207,7 @@ template inline T qFromLittleEndian(const T source) template inline void qToBigEndian(const T src, uchar *dest) { qbswap(src, dest); } template inline void qToLittleEndian(const T src, uchar *dest) -{ ::memcpy(dest, &src, sizeof(T)); } +{ qbcopy_helper(reinterpret_cast(&src), dest, sizeof(T)); } #endif // Q_BYTE_ORDER == Q_BIG_ENDIAN