refactor to use torrent_info with std::shared_ptr (#1006)

This commit is contained in:
Alden Torres 2016-08-17 17:26:35 -04:00 committed by Arvid Norberg
parent 7cee486cf7
commit bb388563b3
46 changed files with 130 additions and 185 deletions

View File

@ -1,3 +1,4 @@
* changes in public API to work with std::shared_ptr<torrent_info>
* extensions API changed to use span and std::shared_ptr
* plugin API changed to handle DHT requests using string_view
* removed support for lt_trackers and metadata_transfer extensions

View File

@ -223,7 +223,7 @@ namespace
// on the C++ side, it will end up freeing the python object
// without holding the GIL and likely crash.
// https://mail.python.org/pipermail/cplusplus-sig/2007-June/012130.html
p.ti = boost::make_shared<torrent_info>(
p.ti = std::make_shared<torrent_info>(
extract<torrent_info const&>(params["ti"]));
}

View File

@ -95,7 +95,7 @@ list file_progress(torrent_handle& handle, int flags)
{
allow_threading_guard guard;
boost::shared_ptr<const torrent_info> ti = handle.torrent_file();
std::shared_ptr<const torrent_info> ti = handle.torrent_file();
if (ti)
{
p.reserve(ti->num_files());
@ -310,7 +310,7 @@ void set_metadata(torrent_handle& handle, std::string const& buf)
#ifndef TORRENT_NO_DEPRECATE
#if BOOST_VERSION > 104200
boost::shared_ptr<const torrent_info> get_torrent_info(torrent_handle const& h)
std::shared_ptr<const torrent_info> get_torrent_info(torrent_handle const& h)
{
allow_threading_guard guard;
return h.torrent_file();
@ -318,13 +318,13 @@ boost::shared_ptr<const torrent_info> get_torrent_info(torrent_handle const& h)
#else
boost::shared_ptr<torrent_info> get_torrent_info(torrent_handle const& h)
std::shared_ptr<torrent_info> get_torrent_info(torrent_handle const& h)
{
// I can't figure out how to expose shared_ptr<const torrent_info>
// as well as supporting mutable instances. So, this hack is better
// than compilation errors. It seems to work on newer versions of boost though
allow_threading_guard guard;
return boost::const_pointer_cast<torrent_info>(h.torrent_file());
return std::const_pointer_cast<torrent_info>(h.torrent_file());
}
#endif

View File

@ -952,7 +952,7 @@ bool handle_alert(libtorrent::session& ses, libtorrent::alert* a
torrent_handle h = p->handle;
if (h.is_valid())
{
boost::shared_ptr<const torrent_info> ti = h.torrent_file();
std::shared_ptr<const torrent_info> ti = h.torrent_file();
create_torrent ct(*ti);
entry te = ct.generate();
std::vector<char> buffer;
@ -2024,7 +2024,7 @@ int main(int argc, char* argv[])
std::vector<pool_file_status> file_status = h.file_status();
std::vector<int> file_prio = h.file_priorities();
std::vector<pool_file_status>::iterator f = file_status.begin();
boost::shared_ptr<const torrent_info> ti = h.torrent_file();
std::shared_ptr<const torrent_info> ti = h.torrent_file();
int p = 0; // this is horizontal position
for (int i = 0; i < ti->num_files(); ++i)

View File

@ -36,17 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/session.hpp"
#include "libtorrent/torrent_info.hpp"
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated"
#endif
#include <boost/make_shared.hpp>
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
int main(int argc, char* argv[])
{
using namespace libtorrent;
@ -70,7 +59,7 @@ int main(int argc, char* argv[])
}
add_torrent_params p;
p.save_path = "./";
p.ti = boost::make_shared<torrent_info>(std::string(argv[1]), std::ref(ec), 0);
p.ti = std::make_shared<torrent_info>(std::string(argv[1]), std::ref(ec), 0);
if (ec)
{
std::fprintf(stderr, "%s\n", ec.message().c_str());

View File

@ -38,10 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <map>
#include <functional>
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/shared_ptr.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include "libtorrent/storage_defs.hpp"
#include "libtorrent/peer_id.hpp" // sha1_hash
#include "libtorrent/version.hpp"
@ -289,7 +285,7 @@ namespace libtorrent
// torrent_info object with the torrent to add. Unless the url or
// info_hash is set, this is required to be initialized.
boost::shared_ptr<torrent_info> ti;
std::shared_ptr<torrent_info> ti;
// If the torrent doesn't have a tracker, but relies on the DHT to find
// peers, the ``trackers`` can specify tracker URLs for the torrent.

View File

@ -38,19 +38,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/heterogeneous_queue.hpp"
#include "libtorrent/stack_allocator.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/shared_ptr.hpp>
#include <boost/config.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <functional>
#include <list>
#include <utility> // for std::forward
#include <mutex>
#include <condition_variable>
namespace libtorrent {
#ifndef TORRENT_DISABLE_EXTENSIONS

View File

@ -33,9 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_DISK_INTERFACE_HPP
#define TORRENT_DISK_INTERFACE_HPP
#include <boost/function/function1.hpp>
#include <boost/shared_ptr.hpp>
#include "libtorrent/bdecode.hpp"
#include <string>
@ -114,4 +111,3 @@ namespace libtorrent
}
#endif

View File

@ -38,12 +38,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/tailqueue.hpp"
#include "libtorrent/peer_id.hpp"
#include <string>
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <string>
#include <boost/function/function1.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
@ -241,4 +241,3 @@ namespace libtorrent
}
#endif // TORRENT_DISK_IO_JOB_HPP

View File

@ -34,14 +34,12 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_RESOLVE_LINKS_HPP
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/shared_ptr.hpp>
#include <boost/unordered_map.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <vector>
#include <utility>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include "libtorrent/export.hpp"
namespace libtorrent
@ -55,15 +53,15 @@ namespace libtorrent
{
struct TORRENT_EXTRA_EXPORT link_t
{
boost::shared_ptr<const torrent_info> ti;
std::shared_ptr<const torrent_info> ti;
std::string save_path;
int file_idx;
};
resolve_links(boost::shared_ptr<torrent_info> ti);
resolve_links(std::shared_ptr<torrent_info> ti);
// check to see if any files are shared with this torrent
void match(boost::shared_ptr<const torrent_info> const& ti
void match(std::shared_ptr<const torrent_info> const& ti
, std::string const& save_path);
std::vector<link_t> const& get_links() const
@ -71,7 +69,7 @@ namespace libtorrent
private:
// this is the torrent we're trying to find files for.
boost::shared_ptr<torrent_info> m_torrent_file;
std::shared_ptr<torrent_info> m_torrent_file;
// each file in m_torrent_file has an entry in this vector. Any file
// that also exists somewhere else, is filled in with the corresponding
@ -86,4 +84,3 @@ namespace libtorrent
}
#endif

View File

@ -444,13 +444,13 @@ namespace libtorrent
// This function adds an extension to this session. The argument is a
// function object that is called with a ``torrent_handle`` and which should
// return a ``boost::shared_ptr<torrent_plugin>``. To write custom
// return a ``std::shared_ptr<torrent_plugin>``. To write custom
// plugins, see `libtorrent plugins`_. For the typical bittorrent client
// all of these extensions should be added. The main plugins implemented
// in libtorrent are:
//
// uTorrent metadata
// Allows peers to download the metadata (.torren files) from the swarm
// Allows peers to download the metadata (.torrent files) from the swarm
// directly. Makes it possible to join a swarm with just a tracker and
// info-hash.
//

View File

@ -188,7 +188,7 @@ namespace libtorrent
// TODO: make this a raw pointer. perhaps keep the shared_ptr
// around further down the object to maintain an owner
boost::shared_ptr<torrent_info> m_torrent_file;
std::shared_ptr<torrent_info> m_torrent_file;
// a back reference to the session
// this torrent belongs to.
@ -945,7 +945,7 @@ namespace libtorrent
torrent_info const& torrent_file() const
{ return *m_torrent_file; }
boost::shared_ptr<const torrent_info> get_torrent_copy();
std::shared_ptr<const torrent_info> get_torrent_copy();
#ifndef TORRENT_NO_DEPRECATE
// deprecated in 1.2

View File

@ -881,7 +881,7 @@ namespace libtorrent
// without metadata only if it was started without a .torrent file, e.g.
// by using the libtorrent extension of just supplying a tracker and
// info-hash.
boost::shared_ptr<const torrent_info> torrent_file() const;
std::shared_ptr<const torrent_info> torrent_file() const;
#ifndef TORRENT_NO_DEPRECATE

View File

@ -161,7 +161,7 @@ namespace libtorrent
// set to point to the ``torrent_info`` object for this torrent. It's
// only included if the torrent status is queried with
// ``torrent_handle::query_torrent_file``.
boost::weak_ptr<const torrent_info> torrent_file;
std::weak_ptr<const torrent_info> torrent_file;
// the time until the torrent will announce itself to the tracker.
time_duration next_announce;

View File

@ -119,7 +119,7 @@ TORRENT_TEST(socks5_tcp_accept)
}
},
[](sim::simulation& sim, lt::session&
, boost::shared_ptr<lt::torrent_info> ti)
, std::shared_ptr<lt::torrent_info> ti)
{
// test connecting to the client via its socks5 listen port
// TODO: maybe we could use peer_conn here instead
@ -161,7 +161,7 @@ TORRENT_TEST(socks4_tcp_accept)
}
},
[](sim::simulation& sim, lt::session&
, boost::shared_ptr<lt::torrent_info> ti)
, std::shared_ptr<lt::torrent_info> ti)
{
fake_peer peer1(sim, "60.0.0.0");
@ -200,7 +200,7 @@ TORRENT_TEST(socks4_tcp_listen_alert)
}
},
[](sim::simulation& sim, lt::session&
, boost::shared_ptr<lt::torrent_info> ti)
, std::shared_ptr<lt::torrent_info> ti)
{
sim.run();
}
@ -230,7 +230,7 @@ TORRENT_TEST(socks5_tcp_listen_alert)
}
},
[](sim::simulation& sim, lt::session&
, boost::shared_ptr<lt::torrent_info> ti)
, std::shared_ptr<lt::torrent_info> ti)
{
sim.run();
}
@ -265,7 +265,7 @@ TORRENT_TEST(socks5_tcp_announce)
}
},
[&tracker_port](sim::simulation& sim, lt::session&
, boost::shared_ptr<lt::torrent_info> ti)
, std::shared_ptr<lt::torrent_info> ti)
{
sim::asio::io_service web_server(sim, address_v4::from_string("2.2.2.2"));
// listen on port 8080

View File

@ -696,7 +696,7 @@ TORRENT_TEST(try_next)
TEST_EQUAL(got_announce, true);
}
boost::shared_ptr<torrent_info> make_torrent(bool priv)
std::shared_ptr<torrent_info> make_torrent(bool priv)
{
file_storage fs;
fs.add_file("foobar", 13241);
@ -713,7 +713,7 @@ boost::shared_ptr<torrent_info> make_torrent(bool priv)
std::vector<char> buf;
bencode(std::back_inserter(buf), e);
error_code ec;
return boost::make_shared<torrent_info>(buf.data(), buf.size(), ec);
return std::make_shared<torrent_info>(buf.data(), int(buf.size()), ec);
}
// make sure we _do_ send our IPv6 address to trackers for private torrents

View File

@ -48,7 +48,7 @@ using namespace libtorrent;
namespace lt = libtorrent;
boost::shared_ptr<torrent_info> create_torrent(file_storage& fs)
std::shared_ptr<torrent_info> create_torrent(file_storage& fs)
{
int const piece_size = 0x4000;
libtorrent::create_torrent t(fs, piece_size);
@ -70,8 +70,8 @@ boost::shared_ptr<torrent_info> create_torrent(file_storage& fs)
bencode(out, tor);
error_code ec;
return boost::make_shared<torrent_info>(
&tmp[0], tmp.size(), std::ref(ec), 0);
return std::make_shared<torrent_info>(
&tmp[0], int(tmp.size()), std::ref(ec), 0);
}
// this is the general template for these tests. create the session with custom
// settings (Settings), set up the test, by adding torrents with certain

View File

@ -105,7 +105,7 @@ namespace libtorrent
// only require the info-hash to match if we actually passed in one
if (resume_ih == ret.info_hash)
{
ret.ti = boost::make_shared<torrent_info>(resume_ih);
ret.ti = std::make_shared<torrent_info>(resume_ih);
error_code err;
if (!ret.ti->parse_info_section(info, err, 0))

View File

@ -31,18 +31,13 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include "libtorrent/resolve_links.hpp"
#include "libtorrent/torrent_info.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/shared_ptr.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace libtorrent
{
#ifndef TORRENT_DISABLE_MUTABLE_TORRENTS
resolve_links::resolve_links(boost::shared_ptr<torrent_info> ti)
resolve_links::resolve_links(std::shared_ptr<torrent_info> ti)
: m_torrent_file(ti)
{
TORRENT_ASSERT(ti);
@ -65,7 +60,7 @@ resolve_links::resolve_links(boost::shared_ptr<torrent_info> ti)
m_links.resize(m_torrent_file->num_files());
}
void resolve_links::match(boost::shared_ptr<const torrent_info> const& ti
void resolve_links::match(std::shared_ptr<const torrent_info> const& ti
, std::string const& save_path)
{
if (!ti) return;
@ -138,4 +133,3 @@ void resolve_links::match(boost::shared_ptr<const torrent_info> const& ti
#endif // TORRENT_DISABLE_MUTABLE_TORRENTS
} // namespace libtorrent

View File

@ -327,9 +327,8 @@ namespace libtorrent
, bool paused
, storage_constructor_type sc)
{
boost::shared_ptr<torrent_info> tip(boost::make_shared<torrent_info>(ti));
add_torrent_params p(sc);
p.ti = tip;
p.ti = std::make_shared<torrent_info>(ti);
p.save_path = save_path;
if (resume_data.type() != entry::undefined_t)
{

View File

@ -4615,7 +4615,7 @@ namespace aux {
else
{
params->url.clear();
params->ti = boost::shared_ptr<torrent_info>(j->buffer.torrent_file);
params->ti = std::shared_ptr<torrent_info>(j->buffer.torrent_file);
handle = add_torrent(*params, ec);
}
@ -4783,7 +4783,7 @@ namespace aux {
if (string_begins_no_case("file://", params.url.c_str()) && !params.ti)
{
std::string const filename = resolve_file_url(params.url);
boost::shared_ptr<torrent_info> t = boost::make_shared<torrent_info>(filename, std::ref(ec), 0);
auto t = std::make_shared<torrent_info>(filename, std::ref(ec), 0);
if (ec) return std::make_pair(ptr_t(), false);
params.url.clear();
params.ti = t;

View File

@ -307,7 +307,7 @@ namespace libtorrent
}
if (!m_torrent_file)
m_torrent_file = (p.ti ? p.ti : boost::make_shared<torrent_info>(info_hash));
m_torrent_file = (p.ti ? p.ti : std::make_shared<torrent_info>(info_hash));
// --- WEB SEEDS ---
@ -462,7 +462,7 @@ namespace libtorrent
}
error_code e;
boost::shared_ptr<torrent_info> tf(boost::make_shared<torrent_info>(data, size, std::ref(e), 0));
auto tf = std::make_shared<torrent_info>(data, size, std::ref(e), 0);
if (e)
{
set_error(e, torrent_status::error_file_url);
@ -2138,7 +2138,7 @@ namespace libtorrent
// as soon as the user is done with its copy of torrent_info
// it will be freed, and we'll have the unloaded version left
if (!m_torrent_file.unique())
m_torrent_file = boost::make_shared<torrent_info>(*m_torrent_file);
m_torrent_file = std::make_shared<torrent_info>(*m_torrent_file);
m_torrent_file->unload();
inc_stats_counter(counters::num_loaded_torrents, -1);
@ -6316,10 +6316,10 @@ namespace libtorrent
}
}
boost::shared_ptr<const torrent_info> torrent::get_torrent_copy()
std::shared_ptr<const torrent_info> torrent::get_torrent_copy()
{
if (!m_torrent_file->is_valid()) return boost::shared_ptr<const torrent_info>();
if (!need_loaded()) return boost::shared_ptr<const torrent_info>();
if (!m_torrent_file->is_valid()) return std::shared_ptr<const torrent_info>();
if (!need_loaded()) return std::shared_ptr<const torrent_info>();
return m_torrent_file;
}

View File

@ -592,10 +592,10 @@ namespace libtorrent
return !m_torrent.expired();
}
boost::shared_ptr<const torrent_info> torrent_handle::torrent_file() const
std::shared_ptr<const torrent_info> torrent_handle::torrent_file() const
{
return sync_call_ret<boost::shared_ptr<const torrent_info>>(
boost::shared_ptr<const torrent_info>(), &torrent::get_torrent_copy);
return sync_call_ret<std::shared_ptr<const torrent_info>>(
std::shared_ptr<const torrent_info>(), &torrent::get_torrent_copy);
}
#ifndef TORRENT_NO_DEPRECATE
@ -604,11 +604,11 @@ namespace libtorrent
// forces the torrent to stay loaded while the client holds it
torrent_info const& torrent_handle::get_torrent_info() const
{
static boost::shared_ptr<const torrent_info> holder[4];
static std::shared_ptr<const torrent_info> holder[4];
static int cursor = 0;
static std::mutex holder_mutex;
boost::shared_ptr<const torrent_info> r = torrent_file();
std::shared_ptr<const torrent_info> r = torrent_file();
std::lock_guard<std::mutex> l(holder_mutex);
holder[cursor++] = r;

View File

@ -55,16 +55,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/lazy_entry.hpp"
#endif
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <set>
#include <ctime>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace libtorrent
{

View File

@ -30,10 +30,6 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/make_shared.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <deque>
#include "make_torrent.hpp"
@ -46,7 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
using namespace libtorrent;
boost::shared_ptr<libtorrent::torrent_info> make_test_torrent(
std::shared_ptr<libtorrent::torrent_info> make_test_torrent(
torrent_args const& args)
{
entry e;
@ -163,7 +159,7 @@ boost::shared_ptr<libtorrent::torrent_info> make_test_torrent(
fwrite(&tmp[0], 1, tmp.size(), f);
fclose(f);
return boost::make_shared<torrent_info>(&tmp[0], int(tmp.size()));
return std::make_shared<torrent_info>(&tmp[0], int(tmp.size()));
}
void generate_files(libtorrent::torrent_info const& ti, std::string const& path

View File

@ -34,7 +34,6 @@ POSSIBILITY OF SUCH DAMAGE.
#define MAKE_TORRENT_HPP
#include "libtorrent/torrent_info.hpp"
#include <boost/shared_ptr.hpp>
#include <vector>
#include <string>
#include "test.hpp"
@ -60,10 +59,9 @@ struct torrent_args
std::string m_http_seed;
};
EXPORT boost::shared_ptr<libtorrent::torrent_info>
EXPORT std::shared_ptr<libtorrent::torrent_info>
make_test_torrent(torrent_args const& args);
EXPORT void generate_files(libtorrent::torrent_info const& ti, std::string const& path, bool random = false);
#endif

View File

@ -51,8 +51,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/broadcast_socket.hpp" // for supports_ipv6()
#include "libtorrent/hex.hpp" // to_hex
#include <boost/make_shared.hpp>
#include "test.hpp"
#include "test_utils.hpp"
#include "setup_transfer.hpp"
@ -595,9 +593,9 @@ int start_proxy(int proxy_type)
using namespace libtorrent;
template <class T>
boost::shared_ptr<T> clone_ptr(boost::shared_ptr<T> const& ptr)
std::shared_ptr<T> clone_ptr(std::shared_ptr<T> const& ptr)
{
return boost::make_shared<T>(*ptr);
return std::make_shared<T>(*ptr);
}
unsigned char random_byte()
@ -640,7 +638,7 @@ lt::file_storage make_file_storage(const int file_sizes[], int num_files
return fs;
}
boost::shared_ptr<lt::torrent_info> make_torrent(const int file_sizes[]
std::shared_ptr<lt::torrent_info> make_torrent(const int file_sizes[]
, int const num_files, int const piece_size)
{
using namespace libtorrent;
@ -658,7 +656,7 @@ boost::shared_ptr<lt::torrent_info> make_torrent(const int file_sizes[]
std::vector<char> buf;
bencode(std::back_inserter(buf), ct.generate());
error_code ec;
return boost::make_shared<torrent_info>(&buf[0], int(buf.size()), ec);
return std::make_shared<torrent_info>(&buf[0], int(buf.size()), ec);
}
void create_random_files(std::string const& path, const int file_sizes[], int num_files)
@ -696,11 +694,11 @@ void create_random_files(std::string const& path, const int file_sizes[], int nu
free(random_data);
}
boost::shared_ptr<torrent_info> create_torrent(std::ostream* file
std::shared_ptr<torrent_info> create_torrent(std::ostream* file
, char const* name, int piece_size
, int num_pieces, bool add_tracker, std::string ssl_certificate)
{
// excercise the path when encountering invalid urls
// exercise the path when encountering invalid urls
char const* invalid_tracker_url = "http:";
char const* invalid_tracker_protocol = "foo://non/existent-name.com/announce";
@ -757,17 +755,17 @@ boost::shared_ptr<torrent_info> create_torrent(std::ostream* file
bencode(out, tor);
error_code ec;
return boost::make_shared<torrent_info>(
&tmp[0], tmp.size(), std::ref(ec), 0);
return std::make_shared<torrent_info>(
&tmp[0], int(tmp.size()), std::ref(ec), 0);
}
std::tuple<torrent_handle, torrent_handle, torrent_handle>
setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3
, bool clear_files, bool use_metadata_transfer, bool connect_peers
, std::string suffix, int piece_size
, boost::shared_ptr<torrent_info>* torrent, bool super_seeding
, std::shared_ptr<torrent_info>* torrent, bool super_seeding
, add_torrent_params const* p, bool stop_lsd, bool use_ssl_ports
, boost::shared_ptr<torrent_info>* torrent2)
, std::shared_ptr<torrent_info>* torrent2)
{
TORRENT_ASSERT(ses1);
TORRENT_ASSERT(ses2);
@ -820,7 +818,7 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3
TORRENT_ASSERT(ses1->id() != ses2->id());
if (ses3) TORRENT_ASSERT(ses3->id() != ses2->id());
boost::shared_ptr<torrent_info> t;
std::shared_ptr<torrent_info> t;
if (torrent == nullptr)
{
error_code ec;

View File

@ -84,12 +84,12 @@ EXPORT void wait_for_downloading(libtorrent::session& ses, char const* name);
EXPORT std::vector<char> generate_piece(int idx, int const piece_size = 0x4000);
EXPORT libtorrent::file_storage make_file_storage(const int file_sizes[], int num_files
, int const piece_size, std::string base_name = "test_dir-");
EXPORT boost::shared_ptr<libtorrent::torrent_info> make_torrent(const int file_sizes[]
EXPORT std::shared_ptr<libtorrent::torrent_info> make_torrent(const int file_sizes[]
, int num_files, int piece_size);
EXPORT void create_random_files(std::string const& path, const int file_sizes[]
, int num_files);
EXPORT boost::shared_ptr<libtorrent::torrent_info> create_torrent(std::ostream* file = 0
EXPORT std::shared_ptr<libtorrent::torrent_info> create_torrent(std::ostream* file = 0
, char const* name = "temporary", int piece_size = 16 * 1024, int num_pieces = 13
, bool add_tracker = true, std::string ssl_certificate = "");
@ -99,9 +99,9 @@ EXPORT std::tuple<libtorrent::torrent_handle
setup_transfer(libtorrent::session* ses1, libtorrent::session* ses2
, libtorrent::session* ses3, bool clear_files, bool use_metadata_transfer = true
, bool connect = true, std::string suffix = "", int piece_size = 16 * 1024
, boost::shared_ptr<libtorrent::torrent_info>* torrent = 0, bool super_seeding = false
, std::shared_ptr<libtorrent::torrent_info>* torrent = 0, bool super_seeding = false
, libtorrent::add_torrent_params const* p = 0, bool stop_lsd = true, bool use_ssl_ports = false
, boost::shared_ptr<libtorrent::torrent_info>* torrent2 = 0);
, std::shared_ptr<libtorrent::torrent_info>* torrent2 = 0);
EXPORT int start_web_server(bool ssl = false, bool chunked = false
, bool keepalive = true);

View File

@ -114,7 +114,7 @@ void test_checking(int flags = read_only_files)
std::vector<char> buf;
bencode(std::back_inserter(buf), t.generate());
boost::shared_ptr<torrent_info> ti(new torrent_info(&buf[0], int(buf.size()), ec));
auto ti = std::make_shared<torrent_info>(&buf[0], int(buf.size()), ec);
std::fprintf(stderr, "generated torrent: %s tmp1_checking/test_torrent_dir\n"
, aux::to_hex(ti->info_hash()).c_str());

View File

@ -404,11 +404,11 @@ entry read_ut_metadata_msg(tcp::socket& s, char* recv_buffer, int size)
}
}
boost::shared_ptr<torrent_info> setup_peer(tcp::socket& s, sha1_hash& ih
std::shared_ptr<torrent_info> setup_peer(tcp::socket& s, sha1_hash& ih
, boost::shared_ptr<lt::session>& ses, bool incoming = true
, int flags = 0, torrent_handle* th = nullptr)
{
boost::shared_ptr<torrent_info> t = ::create_torrent();
std::shared_ptr<torrent_info> t = ::create_torrent();
ih = t->info_hash();
settings_pack sett;
sett.set_str(settings_pack::listen_interfaces, "0.0.0.0:48900");
@ -724,7 +724,7 @@ TORRENT_TEST(multiple_bitfields)
boost::shared_ptr<lt::session> ses;
io_service ios;
tcp::socket s(ios);
boost::shared_ptr<torrent_info> ti = setup_peer(s, ih, ses);
std::shared_ptr<torrent_info> ti = setup_peer(s, ih, ses);
print_session_log(*ses);
char recv_buffer[1000];
@ -758,7 +758,7 @@ TORRENT_TEST(multiple_have_all)
boost::shared_ptr<lt::session> ses;
io_service ios;
tcp::socket s(ios);
boost::shared_ptr<torrent_info> ti = setup_peer(s, ih, ses);
std::shared_ptr<torrent_info> ti = setup_peer(s, ih, ses);
char recv_buffer[1000];
do_handshake(s, ih, recv_buffer);
@ -793,7 +793,7 @@ TORRENT_TEST(dont_have)
boost::shared_ptr<lt::session> ses;
io_service ios;
tcp::socket s(ios);
boost::shared_ptr<torrent_info> ti = setup_peer(s, ih, ses, true, 0, &th);
std::shared_ptr<torrent_info> ti = setup_peer(s, ih, ses, true, 0, &th);
char recv_buffer[1000];
do_handshake(s, ih, recv_buffer);
@ -895,7 +895,7 @@ TORRENT_TEST(invalid_metadata_request)
boost::shared_ptr<lt::session> ses;
io_service ios;
tcp::socket s(ios);
boost::shared_ptr<torrent_info> ti = setup_peer(s, ih, ses);
std::shared_ptr<torrent_info> ti = setup_peer(s, ih, ses);
char recv_buffer[1000];
do_handshake(s, ih, recv_buffer);

View File

@ -119,7 +119,7 @@ void test_transfer(settings_pack const& sett, bool test_deprecated = false)
error_code ec;
create_directory("tmp1_priority", ec);
std::ofstream file("tmp1_priority/temporary");
boost::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
std::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
file.close();
add_torrent_params addp;

View File

@ -139,7 +139,7 @@ session_proxy test_proxy(settings_pack::proxy_type_t proxy_type, int flags)
remove_all("tmp1_privacy", ec);
create_directory("tmp1_privacy", ec);
std::ofstream file(combine_path("tmp1_privacy", "temporary").c_str());
boost::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
std::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
file.close();
char http_tracker_url[200];

View File

@ -84,7 +84,7 @@ void test_read_piece(int flags)
std::vector<char> buf;
bencode(std::back_inserter(buf), t.generate());
boost::shared_ptr<torrent_info> ti(new torrent_info(&buf[0], int(buf.size()), ec));
auto ti = std::make_shared<torrent_info>(&buf[0], int(buf.size()), ec);
std::fprintf(stderr, "generated torrent: %s tmp1_read_piece/test_torrent\n"
, aux::to_hex(ti->info_hash()).c_str());

View File

@ -89,7 +89,7 @@ TORRENT_TEST(recheck)
create_directory("tmp1_recheck", ec);
if (ec) std::fprintf(stderr, "create_directory: %s\n", ec.message().c_str());
std::ofstream file("tmp1_recheck/temporary");
boost::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 4 * 1024 * 1024
std::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 4 * 1024 * 1024
, 7, false);
file.close();

View File

@ -35,7 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/resolve_links.hpp"
#include "libtorrent/file.hpp" // for combine_path
#include "libtorrent/hex.hpp" // to_hex
#include <boost/make_shared.hpp>
#include <functional>
using namespace libtorrent;
@ -98,11 +98,11 @@ TORRENT_TEST(resolve_links)
std::string p = combine_path(path, e.filename1) + ".torrent";
std::fprintf(stderr, "loading %s\n", p.c_str());
boost::shared_ptr<torrent_info> ti1 = boost::make_shared<torrent_info>(p);
std::shared_ptr<torrent_info> ti1 = std::make_shared<torrent_info>(p);
p = combine_path(path, e.filename2) + ".torrent";
std::fprintf(stderr, "loading %s\n", p.c_str());
boost::shared_ptr<torrent_info> ti2 = boost::make_shared<torrent_info>(p);
std::shared_ptr<torrent_info> ti2 = std::make_shared<torrent_info>(p);
std::fprintf(stderr, "resolving\n");
resolve_links l(ti1);

View File

@ -40,8 +40,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/bencode.hpp"
#include "libtorrent/read_resume_data.hpp"
#include <boost/make_shared.hpp>
#include "test.hpp"
#include "settings.hpp"
#include "setup_transfer.hpp"
@ -49,7 +47,7 @@ POSSIBILITY OF SUCH DAMAGE.
using namespace libtorrent;
namespace lt = libtorrent;
boost::shared_ptr<torrent_info> generate_torrent()
std::shared_ptr<torrent_info> generate_torrent()
{
file_storage fs;
fs.add_file("test_resume/tmp1", 128 * 1024 * 8);
@ -71,7 +69,7 @@ boost::shared_ptr<torrent_info> generate_torrent()
std::vector<char> buf;
bencode(std::back_inserter(buf), t.generate());
return boost::make_shared<torrent_info>(&buf[0], buf.size());
return std::make_shared<torrent_info>(&buf[0], int(buf.size()));
}
std::vector<char> generate_resume_data(torrent_info* ti
@ -136,7 +134,7 @@ torrent_handle test_resume_flags(lt::session& ses, int flags
, char const* file_priorities = "1111", char const* resume_file_prio = ""
, bool const test_deprecated = false)
{
boost::shared_ptr<torrent_info> ti = generate_torrent();
std::shared_ptr<torrent_info> ti = generate_torrent();
add_torrent_params p;
std::vector<char> rd = generate_resume_data(ti.get(), resume_file_prio);
@ -203,7 +201,7 @@ void test_piece_priorities(bool test_deprecated = false)
{
settings_pack sett = settings();
lt::session ses(sett);
boost::shared_ptr<torrent_info> ti = generate_torrent();
std::shared_ptr<torrent_info> ti = generate_torrent();
add_torrent_params p;
p.ti = ti;
p.save_path = ".";
@ -717,7 +715,7 @@ void test_zero_file_prio(bool test_deprecated = false)
std::fprintf(stderr, "test_file_prio\n");
lt::session ses;
boost::shared_ptr<torrent_info> ti = generate_torrent();
std::shared_ptr<torrent_info> ti = generate_torrent();
add_torrent_params p;
p.ti = ti;
p.save_path = ".";
@ -785,7 +783,7 @@ void test_seed_mode(bool const file_prio, bool const pieces_have, bool const pie
settings_pack sett = settings();
lt::session ses(sett);
boost::shared_ptr<torrent_info> ti = generate_torrent();
std::shared_ptr<torrent_info> ti = generate_torrent();
add_torrent_params p;
p.ti = ti;
p.save_path = ".";

View File

@ -154,7 +154,7 @@ TORRENT_TEST(load_empty_file)
add_torrent_params atp;
error_code ignore_errors;
atp.ti = boost::make_shared<torrent_info>("", 0, std::ref(ignore_errors));
atp.ti = std::make_shared<torrent_info>("", 0, std::ref(ignore_errors));
atp.save_path = ".";
error_code ec;
torrent_handle h = ses.add_torrent(atp, ec);

View File

@ -183,7 +183,7 @@ void test_ssl(int test_idx, bool use_utp)
create_directory("tmp1_ssl", ec);
std::ofstream file("tmp1_ssl/temporary");
boost::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary"
std::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary"
, 16 * 1024, 13, false, combine_path("..", combine_path("ssl", "root_ca_cert.pem")));
file.close();
@ -345,7 +345,7 @@ attack_t attacks[] =
const int num_attacks = sizeof(attacks)/sizeof(attacks[0]);
bool try_connect(libtorrent::session& ses1, int port
, boost::shared_ptr<torrent_info> const& t, std::uint32_t flags)
, std::shared_ptr<torrent_info> const& t, std::uint32_t flags)
{
using boost::asio::ssl::context;
@ -565,7 +565,7 @@ void test_malicious_peer()
// create torrent
create_directory("tmp3_ssl", ec);
std::ofstream file("tmp3_ssl/temporary");
boost::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary"
std::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary"
, 16 * 1024, 13, false, combine_path("..", combine_path("ssl", "root_ca_cert.pem")));
file.close();

View File

@ -138,8 +138,8 @@ boost::shared_ptr<default_storage> setup_torrent(file_storage& fs
bencode(std::back_inserter(buf), t.generate());
error_code ec;
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(&buf[0]
, buf.size(), std::ref(ec), 0));
auto info = std::make_shared<torrent_info>(&buf[0]
, int(buf.size()), std::ref(ec), 0);
if (ec)
{
@ -174,7 +174,7 @@ std::vector<char> new_piece(int size)
return ret;
}
void run_storage_tests(boost::shared_ptr<torrent_info> info
void run_storage_tests(std::shared_ptr<torrent_info> info
, file_storage& fs
, std::string const& test_path
, libtorrent::storage_mode_t storage_mode
@ -410,7 +410,7 @@ void test_check_files(std::string const& test_path
, libtorrent::storage_mode_t storage_mode
, bool unbuffered)
{
boost::shared_ptr<torrent_info> info;
std::shared_ptr<torrent_info> info;
error_code ec;
const int piece_size = 16 * 1024;
@ -447,7 +447,7 @@ void test_check_files(std::string const& test_path
std::vector<char> buf;
bencode(std::back_inserter(buf), t.generate());
info = boost::make_shared<torrent_info>(&buf[0], buf.size(), std::ref(ec), 0);
info = std::make_shared<torrent_info>(&buf[0], int(buf.size()), std::ref(ec), 0);
aux::session_settings set;
file_pool fp;
@ -484,7 +484,7 @@ void run_test(bool unbuffered)
std::string test_path = current_working_directory();
std::cerr << "\n=== " << test_path << " ===\n" << std::endl;
boost::shared_ptr<torrent_info> info;
std::shared_ptr<torrent_info> info;
std::vector<char> piece0 = new_piece(piece_size);
std::vector<char> piece1 = new_piece(piece_size);
@ -523,7 +523,7 @@ void run_test(bool unbuffered)
std::vector<char> buf;
bencode(std::back_inserter(buf), t.generate());
info = boost::make_shared<torrent_info>(&buf[0], buf.size(), std::ref(ec), 0);
info = std::make_shared<torrent_info>(&buf[0], int(buf.size()), std::ref(ec), 0);
std::cerr << "=== test 1 === " << (unbuffered?"unbuffered":"buffered") << std::endl;
// run_storage_tests writes piece 0, 1 and 2. not 3
@ -567,7 +567,7 @@ void run_test(bool unbuffered)
std::vector<char> buf;
bencode(std::back_inserter(buf), t.generate());
info = boost::make_shared<torrent_info>(&buf[0], buf.size(), std::ref(ec), 0);
info = std::make_shared<torrent_info>(&buf[0], int(buf.size()), std::ref(ec), 0);
std::cerr << "=== test 3 ===" << std::endl;
@ -623,7 +623,7 @@ void test_fastresume(bool const test_deprecated)
if (ec) std::cerr << "create_directory '" << combine_path(test_path, "tmp1")
<< "': " << ec.message() << std::endl;
std::ofstream file(combine_path(test_path, "tmp1/temporary").c_str());
boost::shared_ptr<torrent_info> t = ::create_torrent(&file);
std::shared_ptr<torrent_info> t = ::create_torrent(&file);
file.close();
TEST_CHECK(exists(combine_path(test_path, "tmp1/temporary")));
if (!exists(combine_path(test_path, "tmp1/temporary")))
@ -637,7 +637,7 @@ void test_fastresume(bool const test_deprecated)
error_code ec;
add_torrent_params p;
p.ti = boost::make_shared<torrent_info>(boost::cref(*t));
p.ti = std::make_shared<torrent_info>(std::cref(*t));
p.save_path = combine_path(test_path, "tmp1");
p.storage_mode = storage_mode_sparse;
torrent_handle h = ses.add_torrent(p, ec);
@ -702,7 +702,7 @@ void test_fastresume(bool const test_deprecated)
p.flags &= ~add_torrent_params::flag_paused;
p.flags &= ~add_torrent_params::flag_auto_managed;
p.ti = boost::make_shared<torrent_info>(boost::cref(*t));
p.ti = std::make_shared<torrent_info>(std::cref(*t));
p.save_path = combine_path(test_path, "tmp1");
p.storage_mode = storage_mode_sparse;
torrent_handle h = ses.add_torrent(p, ec);
@ -749,7 +749,7 @@ void test_rename_file_fastresume(bool test_deprecated)
create_directory(combine_path(test_path, "tmp2"), ec);
if (ec) std::cerr << "create_directory: " << ec.message() << std::endl;
std::ofstream file(combine_path(test_path, "tmp2/temporary").c_str());
boost::shared_ptr<torrent_info> t = ::create_torrent(&file);
std::shared_ptr<torrent_info> t = ::create_torrent(&file);
file.close();
TEST_CHECK(exists(combine_path(test_path, "tmp2/temporary")));
@ -759,7 +759,7 @@ void test_rename_file_fastresume(bool test_deprecated)
lt::session ses(pack);
add_torrent_params p;
p.ti = boost::make_shared<torrent_info>(boost::cref(*t));
p.ti = std::make_shared<torrent_info>(std::cref(*t));
p.save_path = combine_path(test_path, "tmp2");
p.storage_mode = storage_mode_sparse;
torrent_handle h = ses.add_torrent(p, ec);
@ -810,7 +810,7 @@ void test_rename_file_fastresume(bool test_deprecated)
p = read_resume_data(&resume_data[0], int(resume_data.size()), ec);
TEST_CHECK(!ec);
}
p.ti = boost::make_shared<torrent_info>(boost::cref(*t));
p.ti = std::make_shared<torrent_info>(std::cref(*t));
p.save_path = combine_path(test_path, "tmp2");
p.storage_mode = storage_mode_sparse;
torrent_handle h = ses.add_torrent(p, ec);

View File

@ -42,17 +42,13 @@ POSSIBILITY OF SUCH DAMAGE.
#include <tuple>
#include <iostream>
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/make_shared.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include "test.hpp"
#include "setup_transfer.hpp"
using namespace libtorrent;
namespace lt = libtorrent;
void test_running_torrent(boost::shared_ptr<torrent_info> info, std::int64_t file_size)
void test_running_torrent(std::shared_ptr<torrent_info> info, std::int64_t file_size)
{
settings_pack pack;
pack.set_int(settings_pack::alert_mask, alert::storage_notification);
@ -171,7 +167,7 @@ TORRENT_TEST(long_names)
std::vector<char> buf;
bencode(std::back_inserter(buf), torrent);
error_code ec;
boost::shared_ptr<torrent_info> ti(boost::make_shared<torrent_info>(&buf[0], buf.size(), std::ref(ec)));
auto ti = std::make_shared<torrent_info>(&buf[0], int(buf.size()), std::ref(ec));
TEST_CHECK(!ec);
}
@ -188,8 +184,8 @@ TORRENT_TEST(total_wanted)
std::vector<char> tmp;
bencode(std::back_inserter(tmp), t.generate());
error_code ec;
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(
&tmp[0], tmp.size(), std::ref(ec)));
auto info = std::make_shared<torrent_info>(
&tmp[0], int(tmp.size()), std::ref(ec));
settings_pack pack;
pack.set_int(settings_pack::alert_mask, alert::storage_notification);
@ -226,8 +222,8 @@ TORRENT_TEST(added_peers)
std::vector<char> tmp;
bencode(std::back_inserter(tmp), t.generate());
error_code ec;
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(
&tmp[0], tmp.size(), std::ref(ec)));
auto info = std::make_shared<torrent_info>(
&tmp[0], int(tmp.size()), std::ref(ec));
settings_pack pack;
pack.set_str(settings_pack::listen_interfaces, "0.0.0.0:48130");
@ -275,7 +271,7 @@ TORRENT_TEST(torrent)
std::back_insert_iterator<std::vector<char> > out(tmp);
bencode(out, t.generate());
error_code ec;
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(&tmp[0], tmp.size(), std::ref(ec), 0));
auto info = std::make_shared<torrent_info>(&tmp[0], int(tmp.size()), std::ref(ec), 0);
TEST_CHECK(info->num_pieces() > 0);
test_running_torrent(info, file_size);
@ -299,10 +295,10 @@ TORRENT_TEST(torrent)
t.set_hash(i, ph);
std::vector<char> tmp;
std::back_insert_iterator<std::vector<char> > out(tmp);
std::back_insert_iterator<std::vector<char>> out(tmp);
bencode(out, t.generate());
error_code ec;
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(&tmp[0], tmp.size(), std::ref(ec), 0));
auto info = std::make_shared<torrent_info>(&tmp[0], int(tmp.size()), std::ref(ec), 0);
test_running_torrent(info, 1024);
}
}
@ -351,7 +347,7 @@ TORRENT_TEST(duplicate_is_not_error)
plugin_creator creator(called);
add_torrent_params p;
p.ti = boost::make_shared<torrent_info>(&tmp[0], tmp.size(), std::ref(ec), 0);
p.ti = std::make_shared<torrent_info>(&tmp[0], int(tmp.size()), std::ref(ec), 0);
p.flags &= ~add_torrent_params::flag_paused;
p.flags &= ~add_torrent_params::flag_auto_managed;
p.flags &= ~add_torrent_params::flag_duplicate_is_error;
@ -402,10 +398,10 @@ TORRENT_TEST(rename_file)
libtorrent::create_torrent t(fs, 128 * 1024, 6);
std::vector<char> tmp;
std::back_insert_iterator<std::vector<char> > out(tmp);
std::back_insert_iterator<std::vector<char>> out(tmp);
bencode(out, t.generate());
error_code ec;
boost::shared_ptr<torrent_info> info(boost::make_shared<torrent_info>(&tmp[0], tmp.size(), std::ref(ec), 0));
auto info = std::make_shared<torrent_info>(&tmp[0], int(tmp.size()), std::ref(ec), 0);
TEST_EQUAL(info->files().file_path(0), combine_path("test3","tmp1"));

View File

@ -331,7 +331,7 @@ TORRENT_TEST(udp_tracker)
remove_all("tmp1_tracker", ec);
create_directory("tmp1_tracker", ec);
std::ofstream file(combine_path("tmp1_tracker", "temporary").c_str());
boost::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
std::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
file.close();
char tracker_url[200];
@ -405,7 +405,7 @@ TORRENT_TEST(http_peers)
remove_all("tmp2_tracker", ec);
create_directory("tmp2_tracker", ec);
std::ofstream file(combine_path("tmp2_tracker", "temporary").c_str());
boost::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
std::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
file.close();
char tracker_url[200];
@ -482,7 +482,7 @@ TORRENT_TEST(current_tracker)
remove_all("tmp3_tracker", ec);
create_directory("tmp3_tracker", ec);
std::ofstream file(combine_path("tmp3_tracker", "temporary").c_str());
boost::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
std::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
file.close();
char tracker_url[200];
@ -541,7 +541,7 @@ void test_proxy(bool proxy_trackers)
remove_all("tmp2_tracker", ec);
create_directory("tmp2_tracker", ec);
std::ofstream file(combine_path("tmp2_tracker", "temporary").c_str());
boost::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
std::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 16 * 1024, 13, false);
file.close();
char tracker_url[200];

View File

@ -227,7 +227,7 @@ void test_transfer(int proxy_type, settings_pack const& sett
create_directory("tmp1_transfer", ec);
std::ofstream file("tmp1_transfer/temporary");
boost::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 32 * 1024, 13, false);
std::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 32 * 1024, 13, false);
file.close();
TEST_CHECK(exists(combine_path("tmp1_transfer", "temporary")));

View File

@ -91,7 +91,7 @@ void test_transfer()
create_directory("./tmp1_utp", ec);
std::ofstream file("./tmp1_utp/temporary");
boost::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 128 * 1024, 6, false);
std::shared_ptr<torrent_info> t = ::create_torrent(&file, "temporary", 128 * 1024, 6, false);
file.close();
// for performance testing

View File

@ -84,8 +84,8 @@ TORRENT_TEST(web_seed_redirect)
std::vector<char> buf;
bencode(std::back_inserter(buf), t.generate());
boost::shared_ptr<torrent_info> torrent_file(new torrent_info(&buf[0]
, int(buf.size()), ec));
auto torrent_file = std::make_shared<torrent_info>(&buf[0]
, int(buf.size()), ec);
{
settings_pack settings;

View File

@ -47,7 +47,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "make_torrent.hpp"
#include <tuple>
#include <boost/make_shared.hpp>
#include <fstream>
#include "setup_transfer.hpp"
@ -75,7 +74,7 @@ static char const* proxy_name[] = {"", "_socks4", "_socks5", "_socks5_pw", "_htt
} // anonymous namespace
// proxy: 0=none, 1=socks4, 2=socks5, 3=socks5_pw 4=http 5=http_pw
void test_transfer(lt::session& ses, boost::shared_ptr<torrent_info> torrent_file
void test_transfer(lt::session& ses, std::shared_ptr<torrent_info> torrent_file
, int proxy, char const* protocol, bool url_seed
, bool chunked_encoding, bool test_ban, bool keepalive, bool proxy_peers)
{
@ -377,7 +376,7 @@ int EXPORT run_http_suite(int proxy, char const* protocol, bool test_url_seed
{
std::fprintf(stderr, "\n\n ==== test case %d ====\n\n\n", a);
boost::shared_ptr<torrent_info> torrent_file = make_test_torrent(test_cases[a]);
std::shared_ptr<torrent_info> torrent_file = make_test_torrent(test_cases[a]);
// if test_ban is true, we create the files with alternate content (that
// doesn't match the hashes in the .torrent file)

View File

@ -37,7 +37,7 @@ int EXPORT run_http_suite(int proxy, char const* protocol
, bool keepalive = true, bool test_rename = false, bool proxy_peers = true);
void EXPORT test_transfer(libtorrent::session& ses
, boost::shared_ptr<libtorrent::torrent_info> torrent_file
, std::shared_ptr<libtorrent::torrent_info> torrent_file
, int proxy = 0, char const* protocol = "http"
, bool url_seed = true, bool chunked_encoding = false
, bool test_ban = false, bool keepalive = true, bool proxy_peers = true);