1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:17:45 +00:00

LibCompress: Switch DeflateCompressor to a fallible constructor

This commit is contained in:
Tim Schumacher 2023-01-03 18:59:27 +01:00 committed by Andreas Kling
parent 8cd2cf2b77
commit f4afee4278
4 changed files with 19 additions and 10 deletions

View file

@ -139,7 +139,7 @@ public:
BEST // WARNING: this one can take an unreasonable amount of time!
};
DeflateCompressor(Core::Stream::Handle<Core::Stream::Stream>, CompressionLevel = CompressionLevel::GOOD);
static ErrorOr<NonnullOwnPtr<DeflateCompressor>> construct(Core::Stream::Handle<Core::Stream::Stream>, CompressionLevel = CompressionLevel::GOOD);
~DeflateCompressor();
virtual ErrorOr<Bytes> read(Bytes) override;
@ -152,6 +152,8 @@ public:
static ErrorOr<ByteBuffer> compress_all(ReadonlyBytes bytes, CompressionLevel = CompressionLevel::GOOD);
private:
DeflateCompressor(NonnullOwnPtr<Core::Stream::LittleEndianOutputBitStream>, CompressionLevel = CompressionLevel::GOOD);
Bytes pending_block() { return { m_rolling_window + block_size, block_size }; }
// LZ77 Compression