MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / decompress

Method decompress

lib/core/bytes.cc:299–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299Bytes Bytes::decompress() const
300{
301 Bytes output;
302 ByteWriter bw(output);
303 Bytes outputBuffer(1024 * 1024);
304
305 z_stream stream = {};
306 inflateInit(&stream);
307 stream.avail_in = size();
308 stream.next_in = (uint8_t*)cbegin();
309
310 int ret;
311 do
312 {
313 stream.avail_out = outputBuffer.size();
314 stream.next_out = &outputBuffer[0];
315 ret = inflate(&stream, Z_NO_FLUSH);
316 if (ret == Z_BUF_ERROR)
317 ret = Z_OK;
318 if ((ret != Z_OK) && (ret != Z_STREAM_END))
319 error("failed to decompress data: {}",
320 stream.msg ? stream.msg : "(unknown error)");
321
322 bw += outputBuffer.slice(0, outputBuffer.size() - stream.avail_out);
323 } while (ret != Z_STREAM_END);
324 inflateEnd(&stream);
325
326 return output;
327}
328
329void Bytes::writeToFile(const std::string& filename) const
330{

Callers 2

sqlReadFluxBytesFunction · 0.80
test_roundtripFunction · 0.80

Calls 3

errorFunction · 0.85
sliceMethod · 0.80
sizeMethod · 0.45

Tested by 1

test_roundtripFunction · 0.64