From 71f1ec0bc865378133ba8348e8294ccf1b311880 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 20 Dec 2017 15:09:20 +0100 Subject: [PATCH] tag/Id3Scan: return std::unique_ptr --- src/decoder/plugins/MadDecoderPlugin.cxx | 4 ++-- src/tag/Id3Scan.cxx | 4 ++-- src/tag/Id3Scan.hxx | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index b5e14c38c..b144c9404 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -351,10 +351,10 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag) } if (mpd_tag) { - Tag *tmp_tag = tag_id3_import(id3_tag); + auto tmp_tag = tag_id3_import(id3_tag); if (tmp_tag != nullptr) { delete *mpd_tag; - *mpd_tag = tmp_tag; + *mpd_tag = tmp_tag.release(); } } diff --git a/src/tag/Id3Scan.cxx b/src/tag/Id3Scan.cxx index 3c8054d1d..cd35386e4 100644 --- a/src/tag/Id3Scan.cxx +++ b/src/tag/Id3Scan.cxx @@ -330,14 +330,14 @@ scan_id3_tag(struct id3_tag *tag, tag_id3_import_ufid(tag, handler, handler_ctx); } -Tag * +std::unique_ptr tag_id3_import(struct id3_tag *tag) { TagBuilder tag_builder; scan_id3_tag(tag, add_tag_handler, &tag_builder); return tag_builder.empty() ? nullptr - : tag_builder.CommitNew().release(); + : tag_builder.CommitNew(); } bool diff --git a/src/tag/Id3Scan.hxx b/src/tag/Id3Scan.hxx index 21d86346c..d81e154a5 100644 --- a/src/tag/Id3Scan.hxx +++ b/src/tag/Id3Scan.hxx @@ -22,6 +22,8 @@ #include "check.h" +#include + class InputStream; struct TagHandler; struct Tag; @@ -31,7 +33,7 @@ bool tag_id3_scan(InputStream &is, const TagHandler &handler, void *handler_ctx); -Tag * +std::unique_ptr tag_id3_import(id3_tag *); /**