diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-11-22 15:20:26 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-11-22 18:07:14 +0000 |
commit | ea707c779cd01c7c2a13d0c339b1fd7c11e95739 (patch) | |
tree | 4b1616dbf2db68393c32a214a87684b2ad596081 | |
parent | wallet2: speedup refresh a bit (diff) | |
download | monero-ea707c779cd01c7c2a13d0c339b1fd7c11e95739.tar.xz |
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
-rw-r--r-- | src/wallet/wallet2.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 005af0a9a..b51a23698 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -470,9 +470,9 @@ void wallet2::pull_blocks(uint64_t start_height, uint64_t& blocks_added) int threads = std::thread::hardware_concurrency(); if (threads > 1) { - crypto::hash *round_block_hashes = new crypto::hash[threads]; - cryptonote::block *round_blocks = new cryptonote::block[threads]; - bool *error = new bool[threads]; + std::vector<crypto::hash> round_block_hashes(threads); + std::vector<cryptonote::block> round_blocks(threads); + std::deque<bool> error(threads); const std::list<block_complete_entry> &blocks = res.blocks; size_t blocks_size = blocks.size(); 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::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++) { 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; } } - delete[] error; - delete[] round_blocks; - delete[] round_block_hashes; } else { |