summaryrefslogtreecommitdiff
path: root/src/fs/io
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-04-26 14:47:00 +0200
committerMax Kellermann <max@musicpd.org>2019-04-26 14:55:00 +0200
commit1cfc0cb874ebf11e4d3a86db762147d324579877 (patch)
tree42b71dc9236849dd9adc2cc407b766ed9564e1d7 /src/fs/io
parent3882c975455065af7ab9e19a5a3efa142660357a (diff)
fs/io/AutoGunzipReader: use std::unique_ptr<>
Diffstat (limited to 'src/fs/io')
-rw-r--r--src/fs/io/AutoGunzipReader.cxx10
-rw-r--r--src/fs/io/AutoGunzipReader.hxx8
2 files changed, 9 insertions, 9 deletions
diff --git a/src/fs/io/AutoGunzipReader.cxx b/src/fs/io/AutoGunzipReader.cxx
index 158df7b52..38ac6a320 100644
--- a/src/fs/io/AutoGunzipReader.cxx
+++ b/src/fs/io/AutoGunzipReader.cxx
@@ -20,10 +20,10 @@
#include "AutoGunzipReader.hxx"
#include "GunzipReader.hxx"
-AutoGunzipReader::~AutoGunzipReader() noexcept
-{
- delete gunzip;
-}
+AutoGunzipReader::AutoGunzipReader(Reader &_next) noexcept
+ :peek(_next) {}
+
+AutoGunzipReader::~AutoGunzipReader() noexcept = default;
gcc_pure
static bool
@@ -43,7 +43,7 @@ AutoGunzipReader::Detect()
}
if (IsGzip(data))
- next = gunzip = new GunzipReader(peek);
+ next = (gunzip = std::make_unique<GunzipReader>(peek)).get();
else
next = &peek;
}
diff --git a/src/fs/io/AutoGunzipReader.hxx b/src/fs/io/AutoGunzipReader.hxx
index 73a4043af..85025437e 100644
--- a/src/fs/io/AutoGunzipReader.hxx
+++ b/src/fs/io/AutoGunzipReader.hxx
@@ -21,7 +21,8 @@
#define MPD_AUTO_GUNZIP_READER_HXX
#include "PeekReader.hxx"
-#include "util/Compiler.h"
+
+#include <memory>
class GunzipReader;
@@ -32,11 +33,10 @@ class GunzipReader;
class AutoGunzipReader final : public Reader {
Reader *next = nullptr;
PeekReader peek;
- GunzipReader *gunzip = nullptr;
+ std::unique_ptr<GunzipReader> gunzip;
public:
- explicit AutoGunzipReader(Reader &_next) noexcept
- :peek(_next) {}
+ explicit AutoGunzipReader(Reader &_next) noexcept;
~AutoGunzipReader() noexcept;
/* virtual methods from class Reader */