From 15939fd87c2c2195b82d880613f29bd4dcf44374 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 4 Sep 2020 17:50:39 +0200 Subject: [PATCH] archive/bzip2: fold Open() into constructor --- src/archive/plugins/Bzip2ArchivePlugin.cxx | 32 ++++++++-------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/archive/plugins/Bzip2ArchivePlugin.cxx b/src/archive/plugins/Bzip2ArchivePlugin.cxx index c3e63c91c..a9dbbd9a6 100644 --- a/src/archive/plugins/Bzip2ArchivePlugin.cxx +++ b/src/archive/plugins/Bzip2ArchivePlugin.cxx @@ -79,25 +79,6 @@ private: bool FillBuffer(); }; -/* single archive handling allocation helpers */ - -inline void -Bzip2InputStream::Open() -{ - bzstream.bzalloc = nullptr; - bzstream.bzfree = nullptr; - bzstream.opaque = nullptr; - - bzstream.next_in = (char *)buffer; - bzstream.avail_in = 0; - - int ret = BZ2_bzDecompressInit(&bzstream, 0, 0); - if (ret != BZ_OK) - throw std::runtime_error("BZ2_bzDecompressInit() has failed"); - - SetReady(); -} - /* archive open && listing routine */ static std::unique_ptr @@ -116,7 +97,18 @@ Bzip2InputStream::Bzip2InputStream(const std::shared_ptr &_input, :InputStream(_uri, _mutex), input(_input) { - Open(); + bzstream.bzalloc = nullptr; + bzstream.bzfree = nullptr; + bzstream.opaque = nullptr; + + bzstream.next_in = (char *)buffer; + bzstream.avail_in = 0; + + int ret = BZ2_bzDecompressInit(&bzstream, 0, 0); + if (ret != BZ_OK) + throw std::runtime_error("BZ2_bzDecompressInit() has failed"); + + SetReady(); } Bzip2InputStream::~Bzip2InputStream() noexcept