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

This commit is contained in:
Max Kellermann 2019-04-26 14:47:00 +02:00
parent 3882c97545
commit 1cfc0cb874
2 changed files with 9 additions and 9 deletions

View File

@ -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;
}

View File

@ -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 */