diff --git a/include/osg/Endian b/include/osg/Endian index e6799b9b2..ec3652e3b 100644 --- a/include/osg/Endian +++ b/include/osg/Endian @@ -32,22 +32,55 @@ inline Endian getCpuByteOrder() return LittleEndian; } - -template -inline void swapBytes( T& in ) +inline void swapBytes( char* in, unsigned int size ) { - if( sizeof( T ) == 1 ) return; - - typedef unsigned char * BytePtr; - - T tmp = in; - BytePtr sptr = (BytePtr)∈ - BytePtr tptr = (BytePtr)&tmp + sizeof(T)-1; - - for( unsigned int i = 0; i < sizeof(T); ++i ) - *(sptr++) = *(dptr--); + char* start = in; + char* end = start+size-1; + while (start