Commit 71f1ec0b authored by Max Kellermann's avatar Max Kellermann

tag/Id3Scan: return std::unique_ptr<Tag>

parent 99f4bce1
...@@ -351,10 +351,10 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag) ...@@ -351,10 +351,10 @@ MadDecoder::ParseId3(size_t tagsize, Tag **mpd_tag)
} }
if (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) { if (tmp_tag != nullptr) {
delete *mpd_tag; delete *mpd_tag;
*mpd_tag = tmp_tag; *mpd_tag = tmp_tag.release();
} }
} }
......
...@@ -330,14 +330,14 @@ scan_id3_tag(struct id3_tag *tag, ...@@ -330,14 +330,14 @@ scan_id3_tag(struct id3_tag *tag,
tag_id3_import_ufid(tag, handler, handler_ctx); tag_id3_import_ufid(tag, handler, handler_ctx);
} }
Tag * std::unique_ptr<Tag>
tag_id3_import(struct id3_tag *tag) tag_id3_import(struct id3_tag *tag)
{ {
TagBuilder tag_builder; TagBuilder tag_builder;
scan_id3_tag(tag, add_tag_handler, &tag_builder); scan_id3_tag(tag, add_tag_handler, &tag_builder);
return tag_builder.empty() return tag_builder.empty()
? nullptr ? nullptr
: tag_builder.CommitNew().release(); : tag_builder.CommitNew();
} }
bool bool
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "check.h" #include "check.h"
#include <memory>
class InputStream; class InputStream;
struct TagHandler; struct TagHandler;
struct Tag; struct Tag;
...@@ -31,7 +33,7 @@ bool ...@@ -31,7 +33,7 @@ bool
tag_id3_scan(InputStream &is, tag_id3_scan(InputStream &is,
const TagHandler &handler, void *handler_ctx); const TagHandler &handler, void *handler_ctx);
Tag * std::unique_ptr<Tag>
tag_id3_import(id3_tag *); tag_id3_import(id3_tag *);
/** /**
......
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