From bac14180e90d234872ba0be6b79356eb3d746a6a Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 14 Jun 2017 09:51:38 +0900 Subject: [PATCH] Apply smart pointers to DSF::File. --- taglib/dsf/dsffile.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/taglib/dsf/dsffile.cpp b/taglib/dsf/dsffile.cpp index a737fdb1..edd0251b 100644 --- a/taglib/dsf/dsffile.cpp +++ b/taglib/dsf/dsffile.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "dsffile.h" @@ -39,19 +40,14 @@ class DSF::File::FilePrivate { public: FilePrivate() : - properties(0), - tag(0) {} - - ~FilePrivate() - { - delete properties; - delete tag; - } + fileSize(0), + metadataOffset(0) {} long long fileSize; long long metadataOffset; - AudioProperties *properties; - ID3v2::Tag *tag; + + SCOPED_PTR properties; + SCOPED_PTR tag; }; //////////////////////////////////////////////////////////////////////////////// @@ -83,12 +79,12 @@ DSF::File::~File() ID3v2::Tag *DSF::File::tag() const { - return d->tag; + return d->tag.get(); } DSF::AudioProperties *DSF::File::audioProperties() const { - return d->properties; + return d->properties.get(); } bool DSF::File::save() @@ -203,15 +199,15 @@ void DSF::File::read(bool readProperties, AudioProperties::ReadStyle propertiesS chunkSize = readBlock(8).toInt64LE(0); - d->properties - = new AudioProperties(readBlock(static_cast(chunkSize)), propertiesStyle); + d->properties.reset( + new AudioProperties(readBlock(static_cast(chunkSize)), propertiesStyle)); // Skip the data chunk // A metadata offset of 0 indicates the absence of an ID3v2 tag if(0 == d->metadataOffset) - d->tag = new ID3v2::Tag(); + d->tag.reset(new ID3v2::Tag()); else - d->tag = new ID3v2::Tag(this, d->metadataOffset); + d->tag.reset(new ID3v2::Tag(this, d->metadataOffset)); }