|
|
@ -329,8 +329,17 @@ std::string decompressZST(const std::byte *in, size_t in_size, std::atomic<bool> |
|
|
|
|
|
|
|
|
|
|
|
// Initialize input and output buffers
|
|
|
|
// Initialize input and output buffers
|
|
|
|
ZSTD_inBuffer input = {in, in_size, 0}; |
|
|
|
ZSTD_inBuffer input = {in, in_size, 0}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Estimate and reserve memory for decompressed data
|
|
|
|
|
|
|
|
size_t estimatedDecompressedSize = ZSTD_getFrameContentSize(in, in_size); |
|
|
|
|
|
|
|
if (estimatedDecompressedSize == ZSTD_CONTENTSIZE_ERROR || estimatedDecompressedSize == ZSTD_CONTENTSIZE_UNKNOWN) { |
|
|
|
|
|
|
|
estimatedDecompressedSize = in_size * 2; // Use a fallback size
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::string decompressedData; |
|
|
|
std::string decompressedData; |
|
|
|
const size_t bufferSize = ZSTD_DStreamOutSize(); // recommended output buffer size
|
|
|
|
decompressedData.reserve(estimatedDecompressedSize); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const size_t bufferSize = ZSTD_DStreamOutSize(); // Recommended output buffer size
|
|
|
|
std::string outputBuffer(bufferSize, '\0'); |
|
|
|
std::string outputBuffer(bufferSize, '\0'); |
|
|
|
|
|
|
|
|
|
|
|
while (input.pos < input.size && !(abort && *abort)) { |
|
|
|
while (input.pos < input.size && !(abort && *abort)) { |
|
|
|