comparison OrthancFramework/Sources/Compression/ZlibCompressor.cpp @ 4492:0b2484663233

Fix build on big-endian architectures
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 30 Jan 2021 18:19:11 +0100
parents a8f554ca5ac6
children 7053502fbf97
comparison
equal deleted inserted replaced
4491:cf44052fdf60 4492:0b2484663233
121 "Cannot guess the uncompressed size of a zlib-encoded buffer"); 121 "Cannot guess the uncompressed size of a zlib-encoded buffer");
122 } 122 }
123 123
124 uint64_t uncompressedSize = ReadUncompressedSizePrefix(compressed, compressedSize); 124 uint64_t uncompressedSize = ReadUncompressedSizePrefix(compressed, compressedSize);
125 125
126 // New in Orthanc 1.9.0: Explicitly use litte-endian encoding in size prefix
127 uncompressedSize = le64toh(uncompressedSize);
128
126 try 129 try
127 { 130 {
128 uncompressed.resize(static_cast<size_t>(uncompressedSize)); 131 uncompressed.resize(static_cast<size_t>(uncompressedSize));
129 } 132 }
130 catch (...) 133 catch (...)
131 { 134 {
132 throw OrthancException(ErrorCode_NotEnoughMemory); 135 throw OrthancException(ErrorCode_NotEnoughMemory);
133 } 136 }
134
135 // New in Orthanc 1.9.0: Explicitly use litte-endian encoding in size prefix
136 uncompressedSize = le64toh(uncompressedSize);
137 137
138 uLongf tmp = static_cast<uLongf>(uncompressedSize); 138 uLongf tmp = static_cast<uLongf>(uncompressedSize);
139 int error = uncompress 139 int error = uncompress
140 (reinterpret_cast<uint8_t*>(&uncompressed[0]), 140 (reinterpret_cast<uint8_t*>(&uncompressed[0]),
141 &tmp, 141 &tmp,