Commit 1cfc0cb8 authored by Max Kellermann's avatar Max Kellermann

fs/io/AutoGunzipReader: use std::unique_ptr<>

parent 3882c975
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
#include "AutoGunzipReader.hxx" #include "AutoGunzipReader.hxx"
#include "GunzipReader.hxx" #include "GunzipReader.hxx"
AutoGunzipReader::~AutoGunzipReader() noexcept AutoGunzipReader::AutoGunzipReader(Reader &_next) noexcept
{ :peek(_next) {}
delete gunzip;
} AutoGunzipReader::~AutoGunzipReader() noexcept = default;
gcc_pure gcc_pure
static bool static bool
...@@ -43,7 +43,7 @@ AutoGunzipReader::Detect() ...@@ -43,7 +43,7 @@ AutoGunzipReader::Detect()
} }
if (IsGzip(data)) if (IsGzip(data))
next = gunzip = new GunzipReader(peek); next = (gunzip = std::make_unique<GunzipReader>(peek)).get();
else else
next = &peek; next = &peek;
} }
......
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
#define MPD_AUTO_GUNZIP_READER_HXX #define MPD_AUTO_GUNZIP_READER_HXX
#include "PeekReader.hxx" #include "PeekReader.hxx"
#include "util/Compiler.h"
#include <memory>
class GunzipReader; class GunzipReader;
...@@ -32,11 +33,10 @@ class GunzipReader; ...@@ -32,11 +33,10 @@ class GunzipReader;
class AutoGunzipReader final : public Reader { class AutoGunzipReader final : public Reader {
Reader *next = nullptr; Reader *next = nullptr;
PeekReader peek; PeekReader peek;
GunzipReader *gunzip = nullptr; std::unique_ptr<GunzipReader> gunzip;
public: public:
explicit AutoGunzipReader(Reader &_next) noexcept explicit AutoGunzipReader(Reader &_next) noexcept;
:peek(_next) {}
~AutoGunzipReader() noexcept; ~AutoGunzipReader() noexcept;
/* virtual methods from class Reader */ /* virtual methods from class Reader */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment