tag/Tag: Merge() returns std::unique_ptr<Tag>
This commit is contained in:
@@ -55,12 +55,12 @@ Tag::Tag(const Tag &other)
|
||||
}
|
||||
}
|
||||
|
||||
Tag *
|
||||
Tag::Merge(const Tag &base, const Tag &add)
|
||||
std::unique_ptr<Tag>
|
||||
Tag::Merge(const Tag &base, const Tag &add) noexcept
|
||||
{
|
||||
TagBuilder builder(add);
|
||||
builder.Complement(base);
|
||||
return builder.CommitNew().release();
|
||||
return builder.CommitNew();
|
||||
}
|
||||
|
||||
Tag *
|
||||
@@ -72,7 +72,7 @@ Tag::MergeReplace(Tag *base, Tag *add)
|
||||
if (base == nullptr)
|
||||
return add;
|
||||
|
||||
Tag *tag = Merge(*base, *add);
|
||||
Tag *tag = Merge(*base, *add).release();
|
||||
delete base;
|
||||
delete add;
|
||||
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
/**
|
||||
* The meta information about a song file. It is a MPD specific
|
||||
@@ -116,8 +117,8 @@ struct Tag {
|
||||
*
|
||||
* @return a newly allocated tag
|
||||
*/
|
||||
gcc_malloc gcc_returns_nonnull
|
||||
static Tag *Merge(const Tag &base, const Tag &add);
|
||||
static std::unique_ptr<Tag> Merge(const Tag &base,
|
||||
const Tag &add) noexcept;
|
||||
|
||||
/**
|
||||
* Merges the data from two tags. Any of the two may be nullptr. Both
|
||||
|
Reference in New Issue
Block a user