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

LibCompress: Switch DeflateDecompressor to a fallible constructor

We don't have anything fallible in there yet, but we will soon switch
the seekback buffer to the new `CircularBuffer`, which has a fallible
constructor.

We have to do the same for the internal `GzipDecompressor::Member`
class, as it needs to construct a `DeflateCompressor` from its received
stream.
This commit is contained in:
Tim Schumacher 2023-01-01 00:38:05 +01:00 committed by Andrew Kaster
parent d717a08003
commit d23f0a7405
4 changed files with 34 additions and 16 deletions

View file

@ -76,7 +76,7 @@ public:
friend CompressedBlock;
friend UncompressedBlock;
DeflateDecompressor(Core::Stream::Handle<Core::Stream::Stream> stream);
static ErrorOr<NonnullOwnPtr<DeflateDecompressor>> construct(Core::Stream::Handle<Core::Stream::Stream> stream);
~DeflateDecompressor();
virtual ErrorOr<Bytes> read(Bytes) override;
@ -88,6 +88,8 @@ public:
static ErrorOr<ByteBuffer> decompress_all(ReadonlyBytes);
private:
DeflateDecompressor(Core::Stream::Handle<Core::Stream::Stream> stream);
ErrorOr<u32> decode_length(u32);
ErrorOr<u32> decode_distance(u32);
ErrorOr<void> decode_codes(CanonicalCode& literal_code, Optional<CanonicalCode>& distance_code);