removed use of boost::bind and boost::scoped_array (#1053)

This commit is contained in:
Alden Torres 2016-09-01 09:43:53 -04:00 committed by Arvid Norberg
parent 5f5589d137
commit 3faa771843
10 changed files with 17 additions and 37 deletions

View File

@ -34,7 +34,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/session_status.hpp"
#include "libtorrent/magnet_uri.hpp"
#include "libtorrent/torrent_handle.hpp"
#include <boost/bind.hpp>
#include <libtorrent.h>
#include <stdarg.h>
@ -60,7 +59,8 @@ namespace
int add_handle(libtorrent::torrent_handle const& h)
{
std::vector<libtorrent::torrent_handle>::iterator i = std::find_if(handles.begin()
, handles.end(), !std::bind(&libtorrent::torrent_handle::is_valid, _1));
, handles.end()
, [](libtorrent::torrent_handle const& h) { return !h.is_valid(); });
if (i != handles.end())
{
*i = h;

View File

@ -29,23 +29,18 @@ namespace
c.set_file_hash(f, sha1_hash(b.arr));
}
void call_python_object(boost::python::object const& obj, int i)
{
obj(i);
}
#ifndef BOOST_NO_EXCEPTIONS
void set_piece_hashes_callback(create_torrent& c, std::string const& p
, boost::python::object cb)
{
set_piece_hashes(c, p, boost::bind(call_python_object, cb, _1));
set_piece_hashes(c, p, [&](int const i) { cb(i); });
}
#else
void set_piece_hashes_callback(create_torrent& c, std::string const& p
, boost::python::object cb)
{
error_code ec;
set_piece_hashes(c, p, boost::bind(call_python_object, cb, _1), ec);
set_piece_hashes(c, p, [&](int const i) { cb(i); }, ec);
}
void set_piece_hashes0(create_torrent& c, std::string const & s)
@ -105,15 +100,10 @@ namespace
{ return FileIter(self, self.num_files()); }
#endif
bool call_python_object2(boost::python::object& obj, std::string const& i)
{
return obj(i);
}
void add_files_callback(file_storage& fs, std::string const& file
, boost::python::object cb, std::uint32_t flags)
{
add_files(fs, file, boost::bind(&call_python_object2, cb, _1), flags);
add_files(fs, file, [&](std::string const& i) { return cb(i); }, flags);
}
}

View File

@ -470,8 +470,9 @@ namespace
TORRENT_ASSERT(public_key.size() == 32);
std::array<char, 32> key;
std::copy(public_key.begin(), public_key.end(), key.begin());
ses.dht_put_item(key, boost::bind(&put_string, _1, _2, _3, _4
, public_key, private_key, data)
ses.dht_put_item(key, [&](entry& e, std::array<char, 64>& sig, std::uint64_t& seq
, std::string const& salt) { put_string(e, sig, seq, salt
, public_key, private_key, data); }
, salt);
}
#endif

View File

@ -44,10 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/debug.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/scoped_array.hpp>
#include <boost/optional.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include "libtorrent/buffer.hpp"
@ -430,7 +427,7 @@ private:
// (outgoing only) synchronize verification constant with
// remote peer, this will hold rc4_decrypt(vc). Destroyed
// after the sync step.
boost::scoped_array<char> m_sync_vc;
std::unique_ptr<char[]> m_sync_vc;
// (incoming only) synchronize hash with remote peer, holds
// the sync hash (hash("req1",secret)). Destroyed after the

View File

@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/kademlia/node.hpp"
#include "libtorrent/kademlia/dht_observer.hpp"
#include "setup_transfer.hpp"
#include <boost/bind.hpp>
#include <memory> // for unique_ptr
#include <random>
#include "libtorrent/socket_io.hpp" // print_endpoint
@ -108,7 +107,8 @@ struct dht_node final : lt::dht::udp_socket_interface
udp::socket::non_blocking_io ioc(true);
sock().io_control(ioc);
sock().async_receive_from(asio::mutable_buffers_1(m_buffer, sizeof(m_buffer))
, m_ep, boost::bind(&dht_node::on_read, this, _1, _2));
, m_ep, [&](lt::error_code const& ec, std::size_t bytes_transferred)
{ this->on_read(ec, bytes_transferred); });
}
#if LIBSIMULATOR_USE_MOVE
@ -161,7 +161,8 @@ struct dht_node final : lt::dht::udp_socket_interface
dht().incoming(m);
sock().async_receive_from(asio::mutable_buffers_1(m_buffer, sizeof(m_buffer))
, m_ep, boost::bind(&dht_node::on_read, this, _1, _2));
, m_ep, [&](lt::error_code const& ec, std::size_t bytes_transferred)
{ this->on_read(ec, bytes_transferred); });
}
bool has_quota() override { return true; }

View File

@ -40,7 +40,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/settings_pack.hpp"
#include "libtorrent/ip_filter.hpp"
#include "libtorrent/alert_types.hpp"
#include <boost/bind.hpp>
#include <fstream>
#include "settings.hpp"

View File

@ -48,7 +48,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/kademlia/ed25519.hpp"
#include "libtorrent/bencode.hpp"
#include "libtorrent/kademlia/item.hpp"
#include <boost/bind.hpp>
namespace lt = libtorrent;

View File

@ -34,7 +34,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/settings_pack.hpp"
#include "libtorrent/alert_types.hpp"
#include "libtorrent/time.hpp" // for clock_type
#include <boost/bind.hpp>
#include "test.hpp"
#include "setup_swarm.hpp"

View File

@ -56,7 +56,6 @@ POSSIBILITY OF SUCH DAMAGE.
#if TORRENT_USE_SYSCTL
#include <sys/sysctl.h>
#include <net/route.h>
#include <boost/scoped_array.hpp>
#endif
#if TORRENT_USE_GETIPFORWARDTABLE || TORRENT_USE_GETADAPTERSADDRESSES
@ -866,7 +865,7 @@ namespace libtorrent
return std::vector<ip_route>();
}
boost::scoped_array<char> buf(new (std::nothrow) char[needed]);
std::unique_ptr<char[]> buf(new (std::nothrow) char[needed]);
if (buf.get() == nullptr)
{
ec = boost::asio::error::no_memory;

View File

@ -65,11 +65,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/io.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
// TODO: 3 use std::unique_ptr
#include <boost/scoped_array.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace
{
// round up to even kilobyte
@ -98,7 +93,7 @@ namespace libtorrent
if (!ec)
{
// parse header
boost::scoped_array<std::uint32_t> header(new std::uint32_t[m_header_size]);
std::unique_ptr<std::uint32_t[]> header(new std::uint32_t[m_header_size]);
file::iovec_t b = {header.get(), size_t(m_header_size) };
int n = m_file.readv(0, &b, 1, ec);
if (ec) return;
@ -308,7 +303,7 @@ namespace libtorrent
int piece = offset / m_piece_size;
int const end = ((offset + size) + m_piece_size - 1) / m_piece_size;
boost::scoped_array<char> buf;
std::unique_ptr<char[]> buf;
std::int64_t piece_offset = offset - std::int64_t(piece) * m_piece_size;
std::int64_t file_offset = 0;
@ -397,7 +392,7 @@ namespace libtorrent
open_file(file::read_write, ec);
if (ec) return;
boost::scoped_array<std::uint32_t> header(new std::uint32_t[m_header_size]);
std::unique_ptr<std::uint32_t[]> header(new std::uint32_t[m_header_size]);
using namespace libtorrent::detail;