diff options
author | Max Kellermann <max@musicpd.org> | 2016-10-29 10:37:18 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-10-29 10:42:56 +0200 |
commit | 9a9da7b0773b5c4863919b84b2269cfeb605ebaa (patch) | |
tree | ab22fc5d2b4fe0552faa82c9db26f447ca91911d /src/command | |
parent | 131441846b58325776841a9da4eae1c4baa30bd3 (diff) |
command/Database: use std::unique_ptr
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/DatabaseCommands.cxx | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/command/DatabaseCommands.cxx b/src/command/DatabaseCommands.cxx index ed50517f6..a4d3da179 100644 --- a/src/command/DatabaseCommands.cxx +++ b/src/command/DatabaseCommands.cxx @@ -35,6 +35,8 @@ #include "SongFilter.hxx" #include "BulkEdit.hxx" +#include <memory> + CommandResult handle_listfiles_db(Client &client, Response &r, const char *uri) { @@ -207,7 +209,7 @@ handle_list(Client &client, Request args, Response &r) return CommandResult::ERROR; } - SongFilter *filter = nullptr; + std::unique_ptr<SongFilter> filter; tag_mask_t group_mask = 0; if (args.size == 1) { @@ -219,7 +221,8 @@ handle_list(Client &client, Request args, Response &r) return CommandResult::ERROR; } - filter = new SongFilter((unsigned)TAG_ARTIST, args.shift()); + filter.reset(new SongFilter((unsigned)TAG_ARTIST, + args.shift())); } while (args.size >= 2 && @@ -239,9 +242,8 @@ handle_list(Client &client, Request args, Response &r) } if (!args.IsEmpty()) { - filter = new SongFilter(); + filter.reset(new SongFilter()); if (!filter->Parse(args, false)) { - delete filter; r.Error(ACK_ERROR_ARG, "not able to parse args"); return CommandResult::ERROR; } @@ -249,7 +251,6 @@ handle_list(Client &client, Request args, Response &r) if (tagType < TAG_NUM_OF_ITEM_TYPES && group_mask & (tag_mask_t(1) << tagType)) { - delete filter; r.Error(ACK_ERROR_ARG, "Conflicting group"); return CommandResult::ERROR; } @@ -257,12 +258,10 @@ handle_list(Client &client, Request args, Response &r) Error error; CommandResult ret = PrintUniqueTags(r, client.partition, - tagType, group_mask, filter, error) + tagType, group_mask, filter.get(), error) ? CommandResult::OK : print_error(r, error); - delete filter; - return ret; } |