mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-24 03:43:27 +01:00
wallet2: minor cleanup
- use std::vector::std::deque to not leak when exceptions happen - use std::unique_ptr instead of the deprecated std::auto_ptr
This commit is contained in:
parent
55a2da7475
commit
ea707c779c
@ -470,9 +470,9 @@ void wallet2::pull_blocks(uint64_t start_height, uint64_t& blocks_added)
|
|||||||
int threads = std::thread::hardware_concurrency();
|
int threads = std::thread::hardware_concurrency();
|
||||||
if (threads > 1)
|
if (threads > 1)
|
||||||
{
|
{
|
||||||
crypto::hash *round_block_hashes = new crypto::hash[threads];
|
std::vector<crypto::hash> round_block_hashes(threads);
|
||||||
cryptonote::block *round_blocks = new cryptonote::block[threads];
|
std::vector<cryptonote::block> round_blocks(threads);
|
||||||
bool *error = new bool[threads];
|
std::deque<bool> error(threads);
|
||||||
const std::list<block_complete_entry> &blocks = res.blocks;
|
const std::list<block_complete_entry> &blocks = res.blocks;
|
||||||
size_t blocks_size = blocks.size();
|
size_t blocks_size = blocks.size();
|
||||||
std::list<block_complete_entry>::const_iterator blocki = blocks.begin();
|
std::list<block_complete_entry>::const_iterator blocki = blocks.begin();
|
||||||
@ -482,7 +482,7 @@ void wallet2::pull_blocks(uint64_t start_height, uint64_t& blocks_added)
|
|||||||
|
|
||||||
boost::asio::io_service ioservice;
|
boost::asio::io_service ioservice;
|
||||||
boost::thread_group threadpool;
|
boost::thread_group threadpool;
|
||||||
std::auto_ptr < boost::asio::io_service::work > work(new boost::asio::io_service::work(ioservice));
|
std::unique_ptr < boost::asio::io_service::work > work(new boost::asio::io_service::work(ioservice));
|
||||||
for (size_t i = 0; i < round_size; i++)
|
for (size_t i = 0; i < round_size; i++)
|
||||||
{
|
{
|
||||||
threadpool.create_thread(boost::bind(&boost::asio::io_service::run, &ioservice));
|
threadpool.create_thread(boost::bind(&boost::asio::io_service::run, &ioservice));
|
||||||
@ -531,9 +531,6 @@ void wallet2::pull_blocks(uint64_t start_height, uint64_t& blocks_added)
|
|||||||
++blocki;
|
++blocki;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete[] error;
|
|
||||||
delete[] round_blocks;
|
|
||||||
delete[] round_block_hashes;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user