summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCompress/Gzip.h
diff options
context:
space:
mode:
authorTim Schumacher <timschumi@gmx.de>2023-01-01 00:38:05 +0100
committerAndrew Kaster <andrewdkaster@gmail.com>2023-01-13 17:34:45 -0700
commitd23f0a7405ee52a627a1c3c84fbd030834ef259b (patch)
tree633176cb68f2f5753a18c044828977f5fc76dea7 /Userland/Libraries/LibCompress/Gzip.h
parentd717a0800319588e012d778fca61af89ddcf8132 (diff)
downloadserenity-d23f0a7405ee52a627a1c3c84fbd030834ef259b.zip
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.
Diffstat (limited to 'Userland/Libraries/LibCompress/Gzip.h')
-rw-r--r--Userland/Libraries/LibCompress/Gzip.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/Userland/Libraries/LibCompress/Gzip.h b/Userland/Libraries/LibCompress/Gzip.h
index 5a038515ab..45c4b01733 100644
--- a/Userland/Libraries/LibCompress/Gzip.h
+++ b/Userland/Libraries/LibCompress/Gzip.h
@@ -56,25 +56,24 @@ public:
private:
class Member {
public:
- Member(BlockHeader header, Core::Stream::Stream& stream)
- : m_header(header)
- , m_stream(Core::Stream::Handle<Core::Stream::Stream>(stream))
- {
- }
+ static ErrorOr<NonnullOwnPtr<Member>> construct(BlockHeader header, Core::Stream::Stream&);
BlockHeader m_header;
- DeflateDecompressor m_stream;
+ NonnullOwnPtr<DeflateDecompressor> m_stream;
Crypto::Checksum::CRC32 m_checksum;
size_t m_nread { 0 };
+
+ private:
+ Member(BlockHeader, NonnullOwnPtr<DeflateDecompressor>);
};
- Member const& current_member() const { return m_current_member.value(); }
- Member& current_member() { return m_current_member.value(); }
+ Member const& current_member() const { return *m_current_member; }
+ Member& current_member() { return *m_current_member; }
NonnullOwnPtr<Core::Stream::Stream> m_input_stream;
u8 m_partial_header[sizeof(BlockHeader)];
size_t m_partial_header_offset { 0 };
- Optional<Member> m_current_member;
+ OwnPtr<Member> m_current_member {};
bool m_eof { false };
};