fixup! refactor: tr_variant API update (#5998) (#6036)

fix use of invalidated pointer in rpcipml
This commit is contained in:
Charles Kerr 2023-09-25 13:24:46 -05:00 committed by GitHub
parent b5fd47e219
commit 114885d67b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -903,7 +903,6 @@ void addTorrentInfo(tr_torrent* tor, TrFormat format, tr_variant* entry, tr_quar
char const* torrentGet(tr_session* session, tr_variant* args_in, tr_variant* args_out, tr_rpc_idle_data* /*idle_data*/)
{
auto const torrents = getTorrents(session, args_in);
tr_variant* const list = tr_variantDictAddList(args_out, TR_KEY_torrents, std::size(torrents) + 1);
auto sv = std::string_view{};
auto const format = tr_variantDictFindStrView(args_in, TR_KEY_format, &sv) && sv == "table"sv ? TrFormat::Table :
@ -945,6 +944,8 @@ char const* torrentGet(tr_session* session, tr_variant* args_in, tr_variant* arg
}
}
auto* const list = tr_variantDictAddList(args_out, TR_KEY_torrents, std::size(torrents) + 1U);
if (format == TrFormat::Table)
{
/* first entry is an array of property names */

View File

@ -9,6 +9,7 @@
#include <cstddef> // size_t
#include <cstdint> // int64_t
#include <optional>
#include <numeric>
#include <string>
#include <string_view>
#include <type_traits> // std::is_same_v
@ -102,9 +103,9 @@ public:
return std::empty(vec_);
}
void reserve(size_t new_cap)
void reserve(size_t const new_cap)
{
vec_.reserve(new_cap);
vec_.reserve(std::max(new_cap, size_t{ 16U }));
}
auto erase(tr_quark const key)