comparison Core/Endianness.h @ 2707:38a3054b22ff

improvement
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 06 Jul 2018 16:51:08 +0200
parents 0511feaf0ec2
children 6356e2ceb493
comparison
equal deleted inserted replaced
2706:0511feaf0ec2 2707:38a3054b22ff
144 #include <stdint.h> 144 #include <stdint.h>
145 145
146 static inline uint16_t __orthanc_bswap16(uint16_t a) 146 static inline uint16_t __orthanc_bswap16(uint16_t a)
147 { 147 {
148 const uint8_t* p = reinterpret_cast<const uint8_t*>(&a); 148 const uint8_t* p = reinterpret_cast<const uint8_t*>(&a);
149 return (static_cast<uint32_t>(p[0]) << 8 | 149 return (static_cast<uint16_t>(p[0]) << 8 |
150 static_cast<uint32_t>(p[1])); 150 static_cast<uint16_t>(p[1]));
151 151
152 // WARNING: The implementation below makes LSB (Linux Standard 152 // WARNING: The implementation below makes LSB (Linux Standard
153 // Base) segfault in release builds. Don't use it!!! 153 // Base) segfault in release builds. Don't use it!!!
154 // return (a << 8) | (a >> 8); 154 // return (a << 8) | (a >> 8);
155 } 155 }