replace typedef with using. replace NULL with nullptr. cleanup page_aligned_allocator
This commit is contained in:
parent
7a477cd938
commit
9df4d4b7f8
@ -243,7 +243,7 @@ void bind_alert()
|
|||||||
{
|
{
|
||||||
using boost::noncopyable;
|
using boost::noncopyable;
|
||||||
|
|
||||||
typedef return_value_policy<return_by_value> by_value;
|
using by_value = return_value_policy<return_by_value>;
|
||||||
|
|
||||||
{
|
{
|
||||||
scope alert_scope = class_<alert, noncopyable >("alert", no_init)
|
scope alert_scope = class_<alert, noncopyable >("alert", no_init)
|
||||||
|
@ -65,11 +65,11 @@ namespace
|
|||||||
|
|
||||||
struct FileIter
|
struct FileIter
|
||||||
{
|
{
|
||||||
typedef lt::file_entry value_type;
|
using value_type = lt::file_entry;
|
||||||
typedef lt::file_entry reference;
|
using reference = lt::file_entry;
|
||||||
typedef lt::file_entry* pointer;
|
using pointer = lt::file_entry*;
|
||||||
typedef int difference_type;
|
using difference_type = int;
|
||||||
typedef std::forward_iterator_tag iterator_category;
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
|
||||||
FileIter(file_storage const& fs, file_index_t i) : m_fs(&fs), m_i(i) {}
|
FileIter(file_storage const& fs, file_index_t i) : m_fs(&fs), m_i(i) {}
|
||||||
FileIter(FileIter const&) = default;
|
FileIter(FileIter const&) = default;
|
||||||
|
@ -211,6 +211,7 @@ def looks_like_variable(line):
|
|||||||
if line.startswith(','): return False
|
if line.startswith(','): return False
|
||||||
if line.startswith(':'): return False
|
if line.startswith(':'): return False
|
||||||
if line.startswith('typedef'): return False
|
if line.startswith('typedef'): return False
|
||||||
|
if line.startswith('using'): return False
|
||||||
if ' = ' in line: return True
|
if ' = ' in line: return True
|
||||||
if line.endswith(';'): return True
|
if line.endswith(';'): return True
|
||||||
return False
|
return False
|
||||||
|
@ -91,9 +91,9 @@ network primitives
|
|||||||
There are a few typedefs in the ``libtorrent`` namespace which pulls
|
There are a few typedefs in the ``libtorrent`` namespace which pulls
|
||||||
in network types from the ``boost::asio`` namespace. These are::
|
in network types from the ``boost::asio`` namespace. These are::
|
||||||
|
|
||||||
typedef boost::asio::ip::address address;
|
using address = boost::asio::ip::address;
|
||||||
typedef boost::asio::ip::address_v4 address_v4;
|
using address_v4 = boost::asio::ip::address_v4;
|
||||||
typedef boost::asio::ip::address_v6 address_v6;
|
using address_v6 = boost::asio::ip::address_v6;
|
||||||
using boost::asio::ip::tcp;
|
using boost::asio::ip::tcp;
|
||||||
using boost::asio::ip::udp;
|
using boost::asio::ip::udp;
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2004 Unicode, Inc.
|
* Copyright 2001-2004 Unicode, Inc.
|
||||||
*
|
*
|
||||||
* Disclaimer
|
* Disclaimer
|
||||||
*
|
*
|
||||||
* This source code is provided as is by Unicode, Inc. No claims are
|
* This source code is provided as is by Unicode, Inc. No claims are
|
||||||
* made as to fitness for any particular purpose. No warranties of any
|
* made as to fitness for any particular purpose. No warranties of any
|
||||||
* kind are expressed or implied. The recipient agrees to determine
|
* kind are expressed or implied. The recipient agrees to determine
|
||||||
@ -10,9 +10,9 @@
|
|||||||
* purchased on magnetic or optical media from Unicode, Inc., the
|
* purchased on magnetic or optical media from Unicode, Inc., the
|
||||||
* sole remedy for any claim will be exchange of defective media
|
* sole remedy for any claim will be exchange of defective media
|
||||||
* within 90 days of receipt.
|
* within 90 days of receipt.
|
||||||
*
|
*
|
||||||
* Limitations on Rights to Redistribute This Code
|
* Limitations on Rights to Redistribute This Code
|
||||||
*
|
*
|
||||||
* Unicode, Inc. hereby grants the right to freely use the information
|
* Unicode, Inc. hereby grants the right to freely use the information
|
||||||
* supplied in this file in the creation of products supporting the
|
* supplied in this file in the creation of products supporting the
|
||||||
* Unicode Standard, and to make copies of this file in any form
|
* Unicode Standard, and to make copies of this file in any form
|
||||||
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
Each routine converts the text between *sourceStart and sourceEnd,
|
Each routine converts the text between *sourceStart and sourceEnd,
|
||||||
putting the result into the buffer between *targetStart and
|
putting the result into the buffer between *targetStart and
|
||||||
targetEnd. Note: the end pointers are *after* the last item: e.g.
|
targetEnd. Note: the end pointers are *after* the last item: e.g.
|
||||||
*(sourceEnd - 1) is the last item.
|
*(sourceEnd - 1) is the last item.
|
||||||
|
|
||||||
The return result indicates whether the conversion was successful,
|
The return result indicates whether the conversion was successful,
|
||||||
@ -71,7 +71,7 @@
|
|||||||
sequence is malformed. When "sourceIllegal" is returned, the source
|
sequence is malformed. When "sourceIllegal" is returned, the source
|
||||||
value will point to the illegal value that caused the problem. E.g.,
|
value will point to the illegal value that caused the problem. E.g.,
|
||||||
in UTF-8 when a sequence is malformed, it points to the start of the
|
in UTF-8 when a sequence is malformed, it points to the start of the
|
||||||
malformed sequence.
|
malformed sequence.
|
||||||
|
|
||||||
Author: Mark E. Davis, 1994.
|
Author: Mark E. Davis, 1994.
|
||||||
Rev History: Rick McGowan, fixes & updates May 2001.
|
Rev History: Rick McGowan, fixes & updates May 2001.
|
||||||
@ -81,12 +81,12 @@
|
|||||||
|
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
typedef std::uint32_t UTF32;
|
using UTF32 = std::uint32_t;
|
||||||
typedef std::uint16_t UTF16;
|
using UTF16 = std::uint16_t;
|
||||||
typedef std::uint8_t UTF8;
|
using UTF8 = std::uint8_t;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
typedef unsigned char Boolean; /* 0 or 1 */
|
using Boolean = unsigned char; /* 0 or 1 */
|
||||||
|
|
||||||
/* Some fundamental constants */
|
/* Some fundamental constants */
|
||||||
#define UNI_REPLACEMENT_CHAR UTF32(0x0000FFFD)
|
#define UNI_REPLACEMENT_CHAR UTF32(0x0000FFFD)
|
||||||
@ -95,12 +95,12 @@ typedef unsigned char Boolean; /* 0 or 1 */
|
|||||||
#define UNI_MAX_UTF32 UTF32(0x7FFFFFFF)
|
#define UNI_MAX_UTF32 UTF32(0x7FFFFFFF)
|
||||||
#define UNI_MAX_LEGAL_UTF32 UTF32(0x0010FFFF)
|
#define UNI_MAX_LEGAL_UTF32 UTF32(0x0010FFFF)
|
||||||
|
|
||||||
typedef enum {
|
enum ConversionResult {
|
||||||
conversionOK, /* conversion successful */
|
conversionOK, /* conversion successful */
|
||||||
sourceExhausted, /* partial character in source, but hit end */
|
sourceExhausted, /* partial character in source, but hit end */
|
||||||
targetExhausted, /* insuff. room in target for conversion */
|
targetExhausted, /* insuff. room in target for conversion */
|
||||||
sourceIllegal /* source sequence is illegal/malformed */
|
sourceIllegal /* source sequence is illegal/malformed */
|
||||||
} ConversionResult;
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
strictConversion = 0,
|
strictConversion = 0,
|
||||||
@ -108,38 +108,36 @@ typedef enum {
|
|||||||
} ConversionFlags;
|
} ConversionFlags;
|
||||||
|
|
||||||
TORRENT_EXTRA_EXPORT ConversionResult ConvertUTF8toUTF16 (
|
TORRENT_EXTRA_EXPORT ConversionResult ConvertUTF8toUTF16 (
|
||||||
const UTF8** sourceStart, const UTF8* sourceEnd,
|
const UTF8** sourceStart, const UTF8* sourceEnd,
|
||||||
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
|
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
TORRENT_EXTRA_EXPORT ConversionResult ConvertUTF16toUTF8 (
|
TORRENT_EXTRA_EXPORT ConversionResult ConvertUTF16toUTF8 (
|
||||||
const UTF16** sourceStart, const UTF16* sourceEnd,
|
const UTF16** sourceStart, const UTF16* sourceEnd,
|
||||||
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
|
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
TORRENT_EXTRA_EXPORT ConversionResult ConvertUTF8toUTF32 (
|
TORRENT_EXTRA_EXPORT ConversionResult ConvertUTF8toUTF32 (
|
||||||
const UTF8** sourceStart, const UTF8* sourceEnd,
|
const UTF8** sourceStart, const UTF8* sourceEnd,
|
||||||
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
|
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
TORRENT_EXTRA_EXPORT ConversionResult ConvertUTF32toUTF8 (
|
TORRENT_EXTRA_EXPORT ConversionResult ConvertUTF32toUTF8 (
|
||||||
const UTF32** sourceStart, const UTF32* sourceEnd,
|
const UTF32** sourceStart, const UTF32* sourceEnd,
|
||||||
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
|
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
TORRENT_EXTRA_EXPORT ConversionResult ConvertUTF16toUTF32 (
|
TORRENT_EXTRA_EXPORT ConversionResult ConvertUTF16toUTF32 (
|
||||||
const UTF16** sourceStart, const UTF16* sourceEnd,
|
const UTF16** sourceStart, const UTF16* sourceEnd,
|
||||||
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
|
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
TORRENT_EXTRA_EXPORT ConversionResult ConvertUTF32toUTF16 (
|
TORRENT_EXTRA_EXPORT ConversionResult ConvertUTF32toUTF16 (
|
||||||
const UTF32** sourceStart, const UTF32* sourceEnd,
|
const UTF32** sourceStart, const UTF32* sourceEnd,
|
||||||
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
|
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
TORRENT_EXTRA_EXPORT Boolean isLegalUTF8Sequence(const UTF8 *source,
|
TORRENT_EXTRA_EXPORT Boolean isLegalUTF8Sequence(const UTF8 *source,
|
||||||
const UTF8 *sourceEnd);
|
const UTF8 *sourceEnd);
|
||||||
|
|
||||||
TORRENT_EXTRA_EXPORT Boolean isLegalUTF8(const UTF8 *source, int length);
|
TORRENT_EXTRA_EXPORT Boolean isLegalUTF8(const UTF8 *source, int length);
|
||||||
|
|
||||||
extern const char trailingBytesForUTF8[256];
|
extern const char trailingBytesForUTF8[256];
|
||||||
extern const UTF32 offsetsFromUTF8[6];
|
extern const UTF32 offsetsFromUTF8[6];
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
|
@ -281,8 +281,17 @@ namespace libtorrent {
|
|||||||
private:
|
private:
|
||||||
aux::allocation_slot m_name_idx;
|
aux::allocation_slot m_name_idx;
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
|
#if defined __clang__ && __clang_major__ > 9
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wshadow-field"
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string TORRENT_DEPRECATED_MEMBER name;
|
std::string TORRENT_DEPRECATED_MEMBER name;
|
||||||
|
|
||||||
|
#if defined __clang__ && __clang_major__ > 9
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,17 +40,11 @@ namespace libtorrent {
|
|||||||
|
|
||||||
TORRENT_EXTRA_EXPORT int page_size();
|
TORRENT_EXTRA_EXPORT int page_size();
|
||||||
|
|
||||||
struct TORRENT_EXTRA_EXPORT page_aligned_allocator
|
TORRENT_EXTRA_EXPORT char* page_malloc(std::size_t bytes);
|
||||||
{
|
TORRENT_EXTRA_EXPORT void page_free(char* block);
|
||||||
typedef int size_type;
|
|
||||||
typedef std::ptrdiff_t difference_type;
|
|
||||||
|
|
||||||
static char* malloc(size_type bytes);
|
|
||||||
static void free(char* block);
|
|
||||||
#ifdef TORRENT_DEBUG_BUFFERS
|
#ifdef TORRENT_DEBUG_BUFFERS
|
||||||
static bool in_use(char const* block);
|
TORRENT_EXTRA_EXPORT bool page_in_use(char const* block);
|
||||||
#endif
|
#endif
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ namespace boost { namespace system {
|
|||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
typedef boost::system::error_code error_code;
|
using error_code = boost::system::error_code;
|
||||||
|
|
||||||
TORRENT_EXTRA_EXPORT char const* parse_int(char const* start
|
TORRENT_EXTRA_EXPORT char const* parse_int(char const* start
|
||||||
, char const* end, char delimiter, std::int64_t& val
|
, char const* end, char delimiter, std::int64_t& val
|
||||||
|
@ -164,11 +164,11 @@ namespace libtorrent {
|
|||||||
{
|
{
|
||||||
friend struct bitfield;
|
friend struct bitfield;
|
||||||
|
|
||||||
typedef bool value_type;
|
using value_type = bool;
|
||||||
typedef ptrdiff_t difference_type;
|
using difference_type = ptrdiff_t;
|
||||||
typedef bool const* pointer;
|
using pointer = bool const*;
|
||||||
typedef bool& reference;
|
using reference = bool&;
|
||||||
typedef std::forward_iterator_tag iterator_category;
|
using iterator_category = std::forward_iterator_tag;
|
||||||
|
|
||||||
bool operator*() { return (*buf & aux::host_to_network(bit)) != 0; }
|
bool operator*() { return (*buf & aux::host_to_network(bit)) != 0; }
|
||||||
const_iterator& operator++() { inc(); return *this; }
|
const_iterator& operator++() { inc(); return *this; }
|
||||||
|
@ -57,8 +57,8 @@ namespace libtorrent {
|
|||||||
TORRENT_EXTRA_EXPORT bool supports_ipv6();
|
TORRENT_EXTRA_EXPORT bool supports_ipv6();
|
||||||
address ensure_v6(address const& a);
|
address ensure_v6(address const& a);
|
||||||
|
|
||||||
typedef std::function<void(udp::endpoint const& from
|
using receive_handler_t = std::function<void(udp::endpoint const& from
|
||||||
, span<char const> buffer)> receive_handler_t;
|
, span<char const> buffer)>;
|
||||||
|
|
||||||
class TORRENT_EXTRA_EXPORT broadcast_socket
|
class TORRENT_EXTRA_EXPORT broadcast_socket
|
||||||
{
|
{
|
||||||
|
@ -46,9 +46,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
#if defined TORRENT_BUILD_SIMULATOR
|
#if defined TORRENT_BUILD_SIMULATOR
|
||||||
typedef sim::asio::high_resolution_timer deadline_timer;
|
using deadline_timer = sim::asio::high_resolution_timer;
|
||||||
#else
|
#else
|
||||||
typedef boost::asio::high_resolution_timer deadline_timer;
|
using deadline_timer = boost::asio::high_resolution_timer;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ namespace aux {
|
|||||||
bool need_readback;
|
bool need_readback;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef tailqueue<disk_io_job> jobqueue_t;
|
using jobqueue_t = tailqueue<disk_io_job>;
|
||||||
|
|
||||||
// this struct holds a number of statistics counters
|
// this struct holds a number of statistics counters
|
||||||
// relevant for the disk io thread and disk cache.
|
// relevant for the disk io thread and disk cache.
|
||||||
|
@ -66,12 +66,12 @@ struct resolver_interface;
|
|||||||
|
|
||||||
constexpr int default_max_bottled_buffer_size = 2 * 1024 * 1024;
|
constexpr int default_max_bottled_buffer_size = 2 * 1024 * 1024;
|
||||||
|
|
||||||
typedef std::function<void(error_code const&
|
using http_handler = std::function<void(error_code const&
|
||||||
, http_parser const&, span<char const> data, http_connection&)> http_handler;
|
, http_parser const&, span<char const> data, http_connection&)>;
|
||||||
|
|
||||||
typedef std::function<void(http_connection&)> http_connect_handler;
|
using http_connect_handler = std::function<void(http_connection&)>;
|
||||||
|
|
||||||
typedef std::function<void(http_connection&, std::vector<tcp::endpoint>&)> http_filter_handler;
|
using http_filter_handler = std::function<void(http_connection&, std::vector<tcp::endpoint>&)>;
|
||||||
|
|
||||||
// when bottled, the last two arguments to the handler
|
// when bottled, the last two arguments to the handler
|
||||||
// will always be 0
|
// will always be 0
|
||||||
|
@ -183,7 +183,7 @@ public:
|
|||||||
char const* session_id() const { return m_session_id.c_str(); }
|
char const* session_id() const { return m_session_id.c_str(); }
|
||||||
std::string const& local_endpoint() const { return m_i2p_local_endpoint; }
|
std::string const& local_endpoint() const { return m_i2p_local_endpoint; }
|
||||||
|
|
||||||
typedef std::function<void(error_code const&, char const*)> name_lookup_handler;
|
using name_lookup_handler = std::function<void(error_code const&, char const*)>;
|
||||||
void async_name_lookup(char const* name, name_lookup_handler handler);
|
void async_name_lookup(char const* name, name_lookup_handler handler);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -51,7 +51,7 @@ class node;
|
|||||||
|
|
||||||
struct find_data : traversal_algorithm
|
struct find_data : traversal_algorithm
|
||||||
{
|
{
|
||||||
typedef std::function<void(std::vector<std::pair<node_entry, std::string>> const&)> nodes_callback;
|
using nodes_callback = std::function<void(std::vector<std::pair<node_entry, std::string>> const&)>;
|
||||||
|
|
||||||
find_data(node& dht_node, node_id const& target
|
find_data(node& dht_node, node_id const& target
|
||||||
, nodes_callback const& ncallback);
|
, nodes_callback const& ncallback);
|
||||||
|
@ -43,7 +43,7 @@ namespace libtorrent { namespace dht {
|
|||||||
class get_item : public find_data
|
class get_item : public find_data
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::function<void(item const&, bool)> data_callback;
|
using data_callback = std::function<void(item const&, bool)>;
|
||||||
|
|
||||||
void got_data(bdecode_node const& v,
|
void got_data(bdecode_node const& v,
|
||||||
public_key const& pk,
|
public_key const& pk,
|
||||||
|
@ -39,7 +39,7 @@ namespace libtorrent { namespace dht {
|
|||||||
|
|
||||||
struct get_peers : find_data
|
struct get_peers : find_data
|
||||||
{
|
{
|
||||||
typedef std::function<void(std::vector<tcp::endpoint> const&)> data_callback;
|
using data_callback = std::function<void(std::vector<tcp::endpoint> const&)>;
|
||||||
|
|
||||||
void got_peers(std::vector<tcp::endpoint> const& peers);
|
void got_peers(std::vector<tcp::endpoint> const& peers);
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class node;
|
|||||||
|
|
||||||
struct put_data: traversal_algorithm
|
struct put_data: traversal_algorithm
|
||||||
{
|
{
|
||||||
typedef std::function<void(item const&, int)> put_callback;
|
using put_callback = std::function<void(item const&, int)>;
|
||||||
|
|
||||||
put_data(node& node, put_callback const& callback);
|
put_data(node& node, put_callback const& callback);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ namespace libtorrent { namespace dht {
|
|||||||
class bootstrap : public get_peers
|
class bootstrap : public get_peers
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef get_peers::nodes_callback done_callback;
|
using done_callback = get_peers::nodes_callback;
|
||||||
|
|
||||||
bootstrap(node& dht_node, node_id const& target
|
bootstrap(node& dht_node, node_id const& target
|
||||||
, done_callback const& callback);
|
, done_callback const& callback);
|
||||||
|
@ -59,7 +59,7 @@ namespace libtorrent { namespace dht {
|
|||||||
struct dht_settings;
|
struct dht_settings;
|
||||||
struct dht_logger;
|
struct dht_logger;
|
||||||
|
|
||||||
typedef aux::vector<node_entry> bucket_t;
|
using bucket_t = aux::vector<node_entry>;
|
||||||
|
|
||||||
struct routing_table_node
|
struct routing_table_node
|
||||||
{
|
{
|
||||||
@ -161,7 +161,7 @@ public:
|
|||||||
void add_router_node(udp::endpoint const& router);
|
void add_router_node(udp::endpoint const& router);
|
||||||
|
|
||||||
// iterates over the router nodes added
|
// iterates over the router nodes added
|
||||||
typedef std::set<udp::endpoint>::const_iterator router_iterator;
|
using router_iterator = std::set<udp::endpoint>::const_iterator;
|
||||||
router_iterator begin() const { return m_router_nodes.begin(); }
|
router_iterator begin() const { return m_router_nodes.begin(); }
|
||||||
router_iterator end() const { return m_router_nodes.end(); }
|
router_iterator end() const { return m_router_nodes.end(); }
|
||||||
|
|
||||||
|
@ -47,10 +47,10 @@ public:
|
|||||||
|
|
||||||
using handler_type = std::function<void(error_code const&)>;
|
using handler_type = std::function<void(error_code const&)>;
|
||||||
|
|
||||||
typedef tcp::socket next_layer_type;
|
using next_layer_type = tcp::socket;
|
||||||
typedef tcp::socket::lowest_layer_type lowest_layer_type;
|
using lowest_layer_type = tcp::socket::lowest_layer_type;
|
||||||
typedef tcp::socket::endpoint_type endpoint_type;
|
using endpoint_type = tcp::socket::endpoint_type;
|
||||||
typedef tcp::socket::protocol_type protocol_type;
|
using protocol_type = tcp::socket::protocol_type;
|
||||||
|
|
||||||
explicit proxy_base(io_service& io_service);
|
explicit proxy_base(io_service& io_service);
|
||||||
~proxy_base();
|
~proxy_base();
|
||||||
@ -64,7 +64,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if BOOST_VERSION >= 106600
|
#if BOOST_VERSION >= 106600
|
||||||
typedef tcp::socket::executor_type executor_type;
|
using executor_type = tcp::socket::executor_type;
|
||||||
executor_type get_executor() { return m_sock.get_executor(); }
|
executor_type get_executor() { return m_sock.get_executor(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -74,13 +74,13 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef typename boost::asio::ssl::stream<Stream> sock_type;
|
using sock_type = typename boost::asio::ssl::stream<Stream>;
|
||||||
typedef typename sock_type::next_layer_type next_layer_type;
|
using next_layer_type = typename sock_type::next_layer_type;
|
||||||
typedef typename Stream::lowest_layer_type lowest_layer_type;
|
using lowest_layer_type = typename Stream::lowest_layer_type;
|
||||||
typedef typename Stream::endpoint_type endpoint_type;
|
using endpoint_type = typename Stream::endpoint_type;
|
||||||
typedef typename Stream::protocol_type protocol_type;
|
using protocol_type = typename Stream::protocol_type;
|
||||||
#if BOOST_VERSION >= 106600
|
#if BOOST_VERSION >= 106600
|
||||||
typedef typename sock_type::executor_type executor_type;
|
using executor_type = typename sock_type::executor_type;
|
||||||
executor_type get_executor() { return m_sock.get_executor(); }
|
executor_type get_executor() { return m_sock.get_executor(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ namespace libtorrent {
|
|||||||
// http seed spec. by John Hoffman
|
// http seed spec. by John Hoffman
|
||||||
enum type_t { url_seed, http_seed };
|
enum type_t { url_seed, http_seed };
|
||||||
|
|
||||||
typedef std::vector<std::pair<std::string, std::string>> headers_t;
|
using headers_t = std::vector<std::pair<std::string, std::string>>;
|
||||||
|
|
||||||
web_seed_entry(std::string const& url_, type_t type_
|
web_seed_entry(std::string const& url_, type_t type_
|
||||||
, std::string const& auth_ = std::string()
|
, std::string const& auth_ = std::string()
|
||||||
@ -351,8 +351,8 @@ namespace libtorrent {
|
|||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// deprecated in 1.0. Use the variants that take an index instead
|
// deprecated in 1.0. Use the variants that take an index instead
|
||||||
// internal_file_entry is no longer exposed in the API
|
// internal_file_entry is no longer exposed in the API
|
||||||
typedef file_storage::iterator file_iterator;
|
using file_iterator = file_storage::iterator;
|
||||||
typedef file_storage::reverse_iterator reverse_file_iterator;
|
using reverse_file_iterator = file_storage::reverse_iterator;
|
||||||
|
|
||||||
// This class will need some explanation. First of all, to get a list of
|
// This class will need some explanation. First of all, to get a list of
|
||||||
// all files in the torrent, you can use ``begin_files()``,
|
// all files in the torrent, you can use ``begin_files()``,
|
||||||
|
@ -336,14 +336,14 @@ namespace libtorrent {
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef std::function<void(aux::listen_socket_handle const&
|
using send_fun_t = std::function<void(aux::listen_socket_handle const&
|
||||||
, udp::endpoint const&
|
, udp::endpoint const&
|
||||||
, span<char const>
|
, span<char const>
|
||||||
, error_code&, udp_send_flags_t)> send_fun_t;
|
, error_code&, udp_send_flags_t)>;
|
||||||
typedef std::function<void(aux::listen_socket_handle const&
|
using send_fun_hostname_t = std::function<void(aux::listen_socket_handle const&
|
||||||
, char const*, int
|
, char const*, int
|
||||||
, span<char const>
|
, span<char const>
|
||||||
, error_code&, udp_send_flags_t)> send_fun_hostname_t;
|
, error_code&, udp_send_flags_t)>;
|
||||||
|
|
||||||
tracker_manager(send_fun_t const& send_fun
|
tracker_manager(send_fun_t const& send_fun
|
||||||
, send_fun_hostname_t const& send_fun_hostname
|
, send_fun_hostname_t const& send_fun_hostname
|
||||||
|
@ -111,8 +111,8 @@ namespace libtorrent {
|
|||||||
return local_endpoint(ec);
|
return local_endpoint(ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef udp::socket::receive_buffer_size receive_buffer_size;
|
using receive_buffer_size = udp::socket::receive_buffer_size;
|
||||||
typedef udp::socket::send_buffer_size send_buffer_size;
|
using send_buffer_size = udp::socket::send_buffer_size;
|
||||||
|
|
||||||
template <class SocketOption>
|
template <class SocketOption>
|
||||||
void get_option(SocketOption const& opt, error_code& ec)
|
void get_option(SocketOption const& opt, error_code& ec)
|
||||||
|
@ -141,7 +141,7 @@ namespace libtorrent {
|
|||||||
incoming_utp_callback_t m_cb;
|
incoming_utp_callback_t m_cb;
|
||||||
|
|
||||||
// replace with a hash-map
|
// replace with a hash-map
|
||||||
typedef std::multimap<std::uint16_t, utp_socket_impl*> socket_map_t;
|
using socket_map_t = std::multimap<std::uint16_t, utp_socket_impl*>;
|
||||||
socket_map_t m_utp_sockets;
|
socket_map_t m_utp_sockets;
|
||||||
|
|
||||||
using socket_vector_t = std::vector<utp_socket_impl*>;
|
using socket_vector_t = std::vector<utp_socket_impl*>;
|
||||||
|
@ -98,12 +98,12 @@ namespace libtorrent {
|
|||||||
char m_storage[sizeof(T)];
|
char m_storage[sizeof(T)];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef big_endian_int<std::uint64_t> be_uint64;
|
using be_uint64 = big_endian_int<std::uint64_t>;
|
||||||
typedef big_endian_int<std::uint32_t> be_uint32;
|
using be_uint32 = big_endian_int<std::uint32_t>;
|
||||||
typedef big_endian_int<std::uint16_t> be_uint16;
|
using be_uint16 = big_endian_int<std::uint16_t>;
|
||||||
typedef big_endian_int<std::int64_t> be_int64;
|
using be_int64 = big_endian_int<std::int64_t>;
|
||||||
typedef big_endian_int<std::int32_t> be_int32;
|
using be_int32 = big_endian_int<std::int32_t>;
|
||||||
typedef big_endian_int<std::int16_t> be_int16;
|
using be_int16 = big_endian_int<std::int16_t>;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
uTP header from BEP 29
|
uTP header from BEP 29
|
||||||
@ -188,7 +188,7 @@ struct TORRENT_EXTRA_EXPORT utp_stream
|
|||||||
using protocol_type = tcp::socket::protocol_type;
|
using protocol_type = tcp::socket::protocol_type;
|
||||||
|
|
||||||
#if BOOST_VERSION >= 106600
|
#if BOOST_VERSION >= 106600
|
||||||
typedef tcp::socket::executor_type executor_type;
|
using executor_type = tcp::socket::executor_type;
|
||||||
executor_type get_executor() { return m_io_service.get_executor(); }
|
executor_type get_executor() { return m_io_service.get_executor(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ namespace libtorrent {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* page_aligned_allocator::malloc(page_aligned_allocator::size_type bytes)
|
char* page_malloc(std::size_t bytes)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(bytes > 0);
|
TORRENT_ASSERT(bytes > 0);
|
||||||
// just sanity check (this needs to be pretty high
|
// just sanity check (this needs to be pretty high
|
||||||
@ -147,7 +147,7 @@ namespace libtorrent {
|
|||||||
#endif // TORRENT_DEBUG_BUFFERS
|
#endif // TORRENT_DEBUG_BUFFERS
|
||||||
}
|
}
|
||||||
|
|
||||||
void page_aligned_allocator::free(char* block)
|
void page_free(char* block)
|
||||||
{
|
{
|
||||||
if (block == nullptr) return;
|
if (block == nullptr) return;
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ namespace libtorrent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_DEBUG_BUFFERS
|
#ifdef TORRENT_DEBUG_BUFFERS
|
||||||
bool page_aligned_allocator::in_use(char const* block)
|
bool page_in_use(char const* block)
|
||||||
{
|
{
|
||||||
const int page = page_size();
|
const int page = page_size();
|
||||||
alloc_header const* h = reinterpret_cast<alloc_header const*>(block - page);
|
alloc_header const* h = reinterpret_cast<alloc_header const*>(block - page);
|
||||||
|
@ -138,7 +138,7 @@ namespace libtorrent {
|
|||||||
#if TORRENT_USE_INVARIANT_CHECKS
|
#if TORRENT_USE_INVARIANT_CHECKS
|
||||||
return m_buffers_in_use.count(buffer) == 1;
|
return m_buffers_in_use.count(buffer) == 1;
|
||||||
#elif defined TORRENT_DEBUG_BUFFERS
|
#elif defined TORRENT_DEBUG_BUFFERS
|
||||||
return page_aligned_allocator::in_use(buffer);
|
return page_in_use(buffer);
|
||||||
#else
|
#else
|
||||||
TORRENT_UNUSED(buffer);
|
TORRENT_UNUSED(buffer);
|
||||||
return true;
|
return true;
|
||||||
@ -227,7 +227,7 @@ namespace libtorrent {
|
|||||||
TORRENT_ASSERT(l.owns_lock());
|
TORRENT_ASSERT(l.owns_lock());
|
||||||
TORRENT_UNUSED(l);
|
TORRENT_UNUSED(l);
|
||||||
|
|
||||||
char* ret = page_aligned_allocator::malloc(default_block_size);
|
char* ret = page_malloc(default_block_size);
|
||||||
|
|
||||||
if (ret == nullptr)
|
if (ret == nullptr)
|
||||||
{
|
{
|
||||||
@ -375,7 +375,7 @@ namespace libtorrent {
|
|||||||
TORRENT_ASSERT(l.owns_lock());
|
TORRENT_ASSERT(l.owns_lock());
|
||||||
TORRENT_UNUSED(l);
|
TORRENT_UNUSED(l);
|
||||||
|
|
||||||
page_aligned_allocator::free(buf);
|
page_free(buf);
|
||||||
|
|
||||||
--m_in_use;
|
--m_in_use;
|
||||||
}
|
}
|
||||||
|
@ -1059,7 +1059,7 @@ constexpr disk_job_flags_t disk_interface::cache_hit;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
typedef status_t (disk_io_thread::*disk_io_fun_t)(disk_io_job* j, jobqueue_t& completed_jobs);
|
using disk_io_fun_t = status_t (disk_io_thread::*)(disk_io_job*, jobqueue_t&);
|
||||||
|
|
||||||
// this is a jump-table for disk I/O jobs
|
// this is a jump-table for disk I/O jobs
|
||||||
std::array<disk_io_fun_t, 15> const job_functions =
|
std::array<disk_io_fun_t, 15> const job_functions =
|
||||||
|
@ -506,7 +506,7 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
|
|||||||
{
|
{
|
||||||
if (family == AF_INET)
|
if (family == AF_INET)
|
||||||
{
|
{
|
||||||
typedef boost::asio::ip::address_v4::bytes_type bytes_t;
|
using bytes_t = boost::asio::ip::address_v4::bytes_type;
|
||||||
bytes_t b;
|
bytes_t b;
|
||||||
std::memset(&b[0], 0xff, b.size());
|
std::memset(&b[0], 0xff, b.size());
|
||||||
for (int i = int(sizeof(bytes_t)) / 8 - 1; i > 0; --i)
|
for (int i = int(sizeof(bytes_t)) / 8 - 1; i > 0; --i)
|
||||||
@ -524,7 +524,7 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
|
|||||||
#if TORRENT_USE_IPV6
|
#if TORRENT_USE_IPV6
|
||||||
else if (family == AF_INET6)
|
else if (family == AF_INET6)
|
||||||
{
|
{
|
||||||
typedef boost::asio::ip::address_v6::bytes_type bytes_t;
|
using bytes_t = boost::asio::ip::address_v6::bytes_type;
|
||||||
bytes_t b;
|
bytes_t b;
|
||||||
std::memset(&b[0], 0xff, b.size());
|
std::memset(&b[0], 0xff, b.size());
|
||||||
for (int i = int(sizeof(bytes_t)) / 8 - 1; i > 0; --i)
|
for (int i = int(sizeof(bytes_t)) / 8 - 1; i > 0; --i)
|
||||||
@ -709,7 +709,7 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
|
|||||||
#elif TORRENT_USE_GETADAPTERSADDRESSES
|
#elif TORRENT_USE_GETADAPTERSADDRESSES
|
||||||
|
|
||||||
#if _WIN32_WINNT >= 0x0501
|
#if _WIN32_WINNT >= 0x0501
|
||||||
typedef ULONG (WINAPI *GetAdaptersAddresses_t)(ULONG,ULONG,PVOID,PIP_ADAPTER_ADDRESSES,PULONG);
|
using GetAdaptersAddresses_t = ULONG (WINAPI *)(ULONG,ULONG,PVOID,PIP_ADAPTER_ADDRESSES,PULONG);
|
||||||
// Get GetAdaptersAddresses() pointer
|
// Get GetAdaptersAddresses() pointer
|
||||||
auto GetAdaptersAddresses =
|
auto GetAdaptersAddresses =
|
||||||
aux::get_library_procedure<aux::iphlpapi, GetAdaptersAddresses_t>("GetAdaptersAddresses");
|
aux::get_library_procedure<aux::iphlpapi, GetAdaptersAddresses_t>("GetAdaptersAddresses");
|
||||||
@ -1031,7 +1031,7 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
|
|||||||
/*
|
/*
|
||||||
move this to enum_net_interfaces
|
move this to enum_net_interfaces
|
||||||
// Get GetAdaptersInfo() pointer
|
// Get GetAdaptersInfo() pointer
|
||||||
typedef DWORD (WINAPI *GetAdaptersInfo_t)(PIP_ADAPTER_INFO, PULONG);
|
using GetAdaptersInfo_t = DWORD (WINAPI*)(PIP_ADAPTER_INFO, PULONG);
|
||||||
GetAdaptersInfo_t GetAdaptersInfo = get_library_procedure<iphlpapi, GetAdaptersInfo_t>("GetAdaptersInfo");
|
GetAdaptersInfo_t GetAdaptersInfo = get_library_procedure<iphlpapi, GetAdaptersInfo_t>("GetAdaptersInfo");
|
||||||
if (GetAdaptersInfo == nullptr)
|
if (GetAdaptersInfo == nullptr)
|
||||||
{
|
{
|
||||||
@ -1079,8 +1079,9 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
|
|||||||
free(adapter_info);
|
free(adapter_info);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef DWORD (WINAPI *GetIfEntry_t)(PMIB_IFROW pIfRow);
|
using GetIfEntry_t = DWORD (WINAPI *)(PMIB_IFROW pIfRow);
|
||||||
auto GetIfEntry = aux::get_library_procedure<aux::iphlpapi, GetIfEntry_t>("GetIfEntry");
|
auto GetIfEntry = aux::get_library_procedure<aux::iphlpapi, GetIfEntry_t>(
|
||||||
|
"GetIfEntry");
|
||||||
|
|
||||||
if (GetIfEntry == nullptr)
|
if (GetIfEntry == nullptr)
|
||||||
{
|
{
|
||||||
@ -1089,9 +1090,9 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if _WIN32_WINNT >= 0x0600
|
#if _WIN32_WINNT >= 0x0600
|
||||||
typedef DWORD (WINAPI *GetIpForwardTable2_t)(
|
using GetIpForwardTable2_t = DWORD (WINAPI *)(
|
||||||
ADDRESS_FAMILY, PMIB_IPFORWARD_TABLE2*);
|
ADDRESS_FAMILY, PMIB_IPFORWARD_TABLE2*);
|
||||||
typedef void (WINAPI *FreeMibTable_t)(PVOID Memory);
|
using FreeMibTable_t = void (WINAPI *)(PVOID Memory);
|
||||||
|
|
||||||
auto GetIpForwardTable2 = aux::get_library_procedure<aux::iphlpapi, GetIpForwardTable2_t>("GetIpForwardTable2");
|
auto GetIpForwardTable2 = aux::get_library_procedure<aux::iphlpapi, GetIpForwardTable2_t>("GetIpForwardTable2");
|
||||||
auto FreeMibTable = aux::get_library_procedure<aux::iphlpapi, FreeMibTable_t>("FreeMibTable");
|
auto FreeMibTable = aux::get_library_procedure<aux::iphlpapi, FreeMibTable_t>("FreeMibTable");
|
||||||
@ -1126,7 +1127,7 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get GetIpForwardTable() pointer
|
// Get GetIpForwardTable() pointer
|
||||||
typedef DWORD (WINAPI *GetIpForwardTable_t)(PMIB_IPFORWARDTABLE pIpForwardTable,PULONG pdwSize,BOOL bOrder);
|
using GetIpForwardTable_t = DWORD (WINAPI*)(PMIB_IPFORWARDTABLE pIpForwardTable,PULONG pdwSize,BOOL bOrder);
|
||||||
|
|
||||||
auto GetIpForwardTable = aux::get_library_procedure<aux::iphlpapi, GetIpForwardTable_t>("GetIpForwardTable");
|
auto GetIpForwardTable = aux::get_library_procedure<aux::iphlpapi, GetIpForwardTable_t>("GetIpForwardTable");
|
||||||
if (GetIpForwardTable == nullptr)
|
if (GetIpForwardTable == nullptr)
|
||||||
|
23
src/file.cpp
23
src/file.cpp
@ -1047,23 +1047,14 @@ namespace {
|
|||||||
#ifdef TORRENT_WINDOWS
|
#ifdef TORRENT_WINDOWS
|
||||||
bool get_manage_volume_privs()
|
bool get_manage_volume_privs()
|
||||||
{
|
{
|
||||||
typedef BOOL (WINAPI *OpenProcessToken_t)(
|
using OpenProcessToken_t = BOOL (WINAPI*)(
|
||||||
HANDLE ProcessHandle,
|
HANDLE, DWORD, PHANDLE);
|
||||||
DWORD DesiredAccess,
|
|
||||||
PHANDLE TokenHandle);
|
|
||||||
|
|
||||||
typedef BOOL (WINAPI *LookupPrivilegeValue_t)(
|
using LookupPrivilegeValue_t = BOOL (WINAPI*)(
|
||||||
LPCSTR lpSystemName,
|
LPCSTR, LPCSTR, PLUID);
|
||||||
LPCSTR lpName,
|
|
||||||
PLUID lpLuid);
|
|
||||||
|
|
||||||
typedef BOOL (WINAPI *AdjustTokenPrivileges_t)(
|
using AdjustTokenPrivileges_t = BOOL (WINAPI*)(
|
||||||
HANDLE TokenHandle,
|
HANDLE, BOOL, PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD);
|
||||||
BOOL DisableAllPrivileges,
|
|
||||||
PTOKEN_PRIVILEGES NewState,
|
|
||||||
DWORD BufferLength,
|
|
||||||
PTOKEN_PRIVILEGES PreviousState,
|
|
||||||
PDWORD ReturnLength);
|
|
||||||
|
|
||||||
auto OpenProcessToken =
|
auto OpenProcessToken =
|
||||||
aux::get_library_procedure<aux::advapi32, OpenProcessToken_t>("OpenProcessToken");
|
aux::get_library_procedure<aux::advapi32, OpenProcessToken_t>("OpenProcessToken");
|
||||||
@ -1101,7 +1092,7 @@ namespace {
|
|||||||
|
|
||||||
void set_file_valid_data(HANDLE f, std::int64_t size)
|
void set_file_valid_data(HANDLE f, std::int64_t size)
|
||||||
{
|
{
|
||||||
typedef BOOL (WINAPI *SetFileValidData_t)(HANDLE, LONGLONG);
|
using SetFileValidData_t = BOOL (WINAPI*)(HANDLE, LONGLONG);
|
||||||
auto SetFileValidData =
|
auto SetFileValidData =
|
||||||
aux::get_library_procedure<aux::kernel32, SetFileValidData_t>("SetFileValidData");
|
aux::get_library_procedure<aux::kernel32, SetFileValidData_t>("SetFileValidData");
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ namespace libtorrent {
|
|||||||
{
|
{
|
||||||
// file prio is only supported on vista and up
|
// file prio is only supported on vista and up
|
||||||
// so load the functions dynamically
|
// so load the functions dynamically
|
||||||
typedef enum {
|
enum FILE_INFO_BY_HANDLE_CLASS_LOCAL {
|
||||||
FileBasicInfo,
|
FileBasicInfo,
|
||||||
FileStandardInfo,
|
FileStandardInfo,
|
||||||
FileNameInfo,
|
FileNameInfo,
|
||||||
@ -71,22 +71,24 @@ namespace libtorrent {
|
|||||||
FileIoPriorityHintInfo,
|
FileIoPriorityHintInfo,
|
||||||
FileRemoteProtocolInfo,
|
FileRemoteProtocolInfo,
|
||||||
MaximumFileInfoByHandleClass
|
MaximumFileInfoByHandleClass
|
||||||
} FILE_INFO_BY_HANDLE_CLASS_LOCAL;
|
};
|
||||||
|
|
||||||
typedef enum {
|
enum PRIORITY_HINT_LOCAL {
|
||||||
IoPriorityHintVeryLow = 0,
|
IoPriorityHintVeryLow = 0,
|
||||||
IoPriorityHintLow,
|
IoPriorityHintLow,
|
||||||
IoPriorityHintNormal,
|
IoPriorityHintNormal,
|
||||||
MaximumIoPriorityHintType
|
MaximumIoPriorityHintType
|
||||||
} PRIORITY_HINT_LOCAL;
|
};
|
||||||
|
|
||||||
typedef struct {
|
struct FILE_IO_PRIORITY_HINT_INFO_LOCAL {
|
||||||
PRIORITY_HINT_LOCAL PriorityHint;
|
PRIORITY_HINT_LOCAL PriorityHint;
|
||||||
} FILE_IO_PRIORITY_HINT_INFO_LOCAL;
|
};
|
||||||
|
|
||||||
typedef BOOL (WINAPI *SetFileInformationByHandle_t)(HANDLE hFile, FILE_INFO_BY_HANDLE_CLASS_LOCAL FileInformationClass, LPVOID lpFileInformation, DWORD dwBufferSize);
|
using SetFileInformationByHandle_t = BOOL (WINAPI *)(HANDLE
|
||||||
|
, FILE_INFO_BY_HANDLE_CLASS_LOCAL, LPVOID, DWORD);
|
||||||
auto SetFileInformationByHandle =
|
auto SetFileInformationByHandle =
|
||||||
aux::get_library_procedure<aux::kernel32, SetFileInformationByHandle_t>("SetFileInformationByHandle");
|
aux::get_library_procedure<aux::kernel32, SetFileInformationByHandle_t>(
|
||||||
|
"SetFileInformationByHandle");
|
||||||
|
|
||||||
if (SetFileInformationByHandle == nullptr) return;
|
if (SetFileInformationByHandle == nullptr) return;
|
||||||
|
|
||||||
|
@ -3452,10 +3452,10 @@ get_out:
|
|||||||
m_pad_blocks.insert(block);
|
m_pad_blocks.insert(block);
|
||||||
// if we mark and entire piece as a pad file, we need to also
|
// if we mark and entire piece as a pad file, we need to also
|
||||||
// consder that piece as "had" and increment some counters
|
// consder that piece as "had" and increment some counters
|
||||||
typedef std::set<piece_block>::iterator iter;
|
using iter = std::set<piece_block>::const_iterator;
|
||||||
iter begin = m_pad_blocks.lower_bound(piece_block(block.piece_index, 0));
|
iter const begin = m_pad_blocks.lower_bound(piece_block(block.piece_index, 0));
|
||||||
int const blocks = blocks_in_piece(block.piece_index);
|
int const blocks = blocks_in_piece(block.piece_index);
|
||||||
iter end = m_pad_blocks.upper_bound(piece_block(block.piece_index, blocks));
|
iter const end = m_pad_blocks.upper_bound(piece_block(block.piece_index, blocks));
|
||||||
if (std::distance(begin, end) == blocks)
|
if (std::distance(begin, end) == blocks)
|
||||||
{
|
{
|
||||||
// the entire piece is a pad file
|
// the entire piece is a pad file
|
||||||
|
@ -449,7 +449,7 @@ constexpr int CLOSE_FILE_INTERVAL = 0;
|
|||||||
|
|
||||||
void run_all_updates(aux::session_impl& ses)
|
void run_all_updates(aux::session_impl& ses)
|
||||||
{
|
{
|
||||||
typedef void (aux::session_impl::*fun_t)();
|
using fun_t = void (aux::session_impl::*)();
|
||||||
for (int i = 0; i < settings_pack::num_string_settings; ++i)
|
for (int i = 0; i < settings_pack::num_string_settings; ++i)
|
||||||
{
|
{
|
||||||
fun_t const& f = str_settings[i].fun;
|
fun_t const& f = str_settings[i].fun;
|
||||||
@ -516,7 +516,7 @@ constexpr int CLOSE_FILE_INTERVAL = 0;
|
|||||||
void apply_pack(settings_pack const* pack, aux::session_settings& sett
|
void apply_pack(settings_pack const* pack, aux::session_settings& sett
|
||||||
, aux::session_impl* ses)
|
, aux::session_impl* ses)
|
||||||
{
|
{
|
||||||
typedef void (aux::session_impl::*fun_t)();
|
using fun_t = void (aux::session_impl::*)();
|
||||||
std::vector<fun_t> callbacks;
|
std::vector<fun_t> callbacks;
|
||||||
|
|
||||||
for (auto const& p : pack->m_strings)
|
for (auto const& p : pack->m_strings)
|
||||||
|
@ -19,13 +19,13 @@ changelog at the end of the file.
|
|||||||
#include <boost/detail/endian.hpp> // for BIG_ENDIAN and LITTLE_ENDIAN macros
|
#include <boost/detail/endian.hpp> // for BIG_ENDIAN and LITTLE_ENDIAN macros
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
|
||||||
typedef std::uint32_t u32;
|
|
||||||
typedef std::uint8_t u8;
|
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using u32 = std::uint32_t;
|
||||||
|
using u8 = std::uint8_t;
|
||||||
|
|
||||||
union CHAR64LONG16
|
union CHAR64LONG16
|
||||||
{
|
{
|
||||||
u8 c[64];
|
u8 c[64];
|
||||||
|
@ -160,7 +160,7 @@ static int sha512_compress(sha512_ctx *md, unsigned char *buf)
|
|||||||
@return 0 if successful
|
@return 0 if successful
|
||||||
*/
|
*/
|
||||||
int SHA512_init(sha512_ctx* md) {
|
int SHA512_init(sha512_ctx* md) {
|
||||||
if (md == NULL) return 1;
|
if (md == nullptr) return 1;
|
||||||
|
|
||||||
md->curlen = 0;
|
md->curlen = 0;
|
||||||
md->length = 0;
|
md->length = 0;
|
||||||
@ -188,8 +188,8 @@ int SHA512_update(sha512_ctx* md, std::uint8_t const* in, std::size_t inlen)
|
|||||||
std::size_t n;
|
std::size_t n;
|
||||||
std::size_t i;
|
std::size_t i;
|
||||||
int err;
|
int err;
|
||||||
if (md == NULL) return 1;
|
if (md == nullptr) return 1;
|
||||||
if (in == NULL) return 1;
|
if (in == nullptr) return 1;
|
||||||
if (md->curlen > sizeof(md->buf)) {
|
if (md->curlen > sizeof(md->buf)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -234,8 +234,8 @@ int SHA512_final(std::uint8_t* out, sha512_ctx* md)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (md == NULL) return 1;
|
if (md == nullptr) return 1;
|
||||||
if (out == NULL) return 1;
|
if (out == nullptr) return 1;
|
||||||
|
|
||||||
if (md->curlen >= sizeof(md->buf)) {
|
if (md->curlen >= sizeof(md->buf)) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -196,7 +196,7 @@ namespace aux {
|
|||||||
|
|
||||||
void socket_type::destruct()
|
void socket_type::destruct()
|
||||||
{
|
{
|
||||||
typedef tcp::socket tcp_socket;
|
using tcp_socket = tcp::socket;
|
||||||
switch (m_type)
|
switch (m_type)
|
||||||
{
|
{
|
||||||
case 0: break;
|
case 0: break;
|
||||||
|
@ -320,7 +320,7 @@ void wait_for_listen(lt::session& ses, char const* name)
|
|||||||
alert const* a = nullptr;
|
alert const* a = nullptr;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
listen_done = print_alerts(ses, name, true, true, [&listen_done](lt::alert const* al)
|
listen_done = print_alerts(ses, name, true, true, [](lt::alert const* al)
|
||||||
{ return alert_cast<listen_failed_alert>(al) || alert_cast<listen_succeeded_alert>(al); }
|
{ return alert_cast<listen_failed_alert>(al) || alert_cast<listen_succeeded_alert>(al); }
|
||||||
, false);
|
, false);
|
||||||
if (listen_done) break;
|
if (listen_done) break;
|
||||||
@ -338,7 +338,7 @@ void wait_for_downloading(lt::session& ses, char const* name)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
downloading_done = print_alerts(ses, name, true, true
|
downloading_done = print_alerts(ses, name, true, true
|
||||||
, [&downloading_done](lt::alert const* al)
|
, [](lt::alert const* al)
|
||||||
{
|
{
|
||||||
state_changed_alert const* sc = alert_cast<state_changed_alert>(al);
|
state_changed_alert const* sc = alert_cast<state_changed_alert>(al);
|
||||||
return sc && sc->state == torrent_status::downloading;
|
return sc && sc->state == torrent_status::downloading;
|
||||||
@ -391,9 +391,9 @@ void print_ses_rate(float const time
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
typedef DWORD pid_type;
|
using pid_type = DWORD;
|
||||||
#else
|
#else
|
||||||
typedef pid_t pid_type;
|
using pid_type = pid_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -75,7 +75,7 @@ int EXPORT print_failures();
|
|||||||
int EXPORT test_counter();
|
int EXPORT test_counter();
|
||||||
void EXPORT reset_output();
|
void EXPORT reset_output();
|
||||||
|
|
||||||
typedef void (*unit_test_fun_t)();
|
using unit_test_fun_t = void (*)();
|
||||||
|
|
||||||
struct unit_test_t
|
struct unit_test_t
|
||||||
{
|
{
|
||||||
@ -100,7 +100,7 @@ extern int _g_test_idx;
|
|||||||
t.name = __FILE__ "." #test_name; \
|
t.name = __FILE__ "." #test_name; \
|
||||||
t.num_failures = 0; \
|
t.num_failures = 0; \
|
||||||
t.run = false; \
|
t.run = false; \
|
||||||
t.output = NULL; \
|
t.output = nullptr; \
|
||||||
_g_num_unit_tests++; \
|
_g_num_unit_tests++; \
|
||||||
} \
|
} \
|
||||||
} BOOST_PP_CAT(_static_registrar_, test_name); \
|
} BOOST_PP_CAT(_static_registrar_, test_name); \
|
||||||
|
@ -113,7 +113,7 @@ void peer_connection::start()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef std::vector<std::shared_ptr<peer_connection>> connections_t;
|
using connections_t = std::vector<std::shared_ptr<peer_connection>>;
|
||||||
|
|
||||||
void do_change_rate(bandwidth_channel& t1, bandwidth_channel& t2, int limit)
|
void do_change_rate(bandwidth_channel& t1, bandwidth_channel& t2, int limit)
|
||||||
{
|
{
|
||||||
|
@ -212,7 +212,7 @@ TORRENT_TEST(chained_buffer)
|
|||||||
|
|
||||||
// there are no buffers, we should not be able to allocate
|
// there are no buffers, we should not be able to allocate
|
||||||
// an appendix in an existing buffer
|
// an appendix in an existing buffer
|
||||||
TEST_EQUAL(b.allocate_appendix(1), 0);
|
TEST_EQUAL(b.allocate_appendix(1), static_cast<char*>(nullptr));
|
||||||
|
|
||||||
char* b1 = allocate_buffer(512);
|
char* b1 = allocate_buffer(512);
|
||||||
std::memcpy(b1, data_test, 6);
|
std::memcpy(b1, data_test, 6);
|
||||||
|
@ -184,7 +184,7 @@ void run_suite(std::string const& protocol
|
|||||||
if (ps.type != settings_pack::none)
|
if (ps.type != settings_pack::none)
|
||||||
ps.port = aux::numeric_cast<std::uint16_t>(start_proxy(ps.type));
|
ps.port = aux::numeric_cast<std::uint16_t>(start_proxy(ps.type));
|
||||||
|
|
||||||
typedef boost::optional<error_code> err;
|
using err = boost::optional<error_code>;
|
||||||
|
|
||||||
char url[256];
|
char url[256];
|
||||||
std::snprintf(url, sizeof(url), "%s://127.0.0.1:%d/", protocol.c_str(), port);
|
std::snprintf(url, sizeof(url), "%s://127.0.0.1:%d/", protocol.c_str(), port);
|
||||||
|
@ -239,7 +239,7 @@ TORRENT_TEST(http_parser)
|
|||||||
TEST_CHECK(parser.header("content-type") == "text/plain");
|
TEST_CHECK(parser.header("content-type") == "text/plain");
|
||||||
TEST_CHECK(atoi(parser.header("content-length").c_str()) == 20);
|
TEST_CHECK(atoi(parser.header("content-length").c_str()) == 20);
|
||||||
TEST_CHECK(parser.chunked_encoding());
|
TEST_CHECK(parser.chunked_encoding());
|
||||||
typedef std::pair<std::int64_t, std::int64_t> chunk_range;
|
using chunk_range = std::pair<std::int64_t, std::int64_t>;
|
||||||
std::vector<chunk_range> cmp;
|
std::vector<chunk_range> cmp;
|
||||||
cmp.push_back(chunk_range(96, 100));
|
cmp.push_back(chunk_range(96, 100));
|
||||||
cmp.push_back(chunk_range(106, 122));
|
cmp.push_back(chunk_range(106, 122));
|
||||||
|
@ -183,7 +183,7 @@ std::shared_ptr<piece_picker> setup_picker(
|
|||||||
int const idx = static_cast<int>(i);
|
int const idx = static_cast<int>(i);
|
||||||
if (priority[idx] == 0) break;
|
if (priority[idx] == 0) break;
|
||||||
download_priority_t const prio((priority[idx] - '0') & 0xff);
|
download_priority_t const prio((priority[idx] - '0') & 0xff);
|
||||||
assert(prio >= dont_download);
|
TEST_CHECK(prio >= dont_download);
|
||||||
p->set_piece_priority(i, prio);
|
p->set_piece_priority(i, prio);
|
||||||
|
|
||||||
TEST_CHECK(p->piece_priority(i) == prio);
|
TEST_CHECK(p->piece_priority(i) == prio);
|
||||||
@ -2067,10 +2067,10 @@ TORRENT_TEST(mark_as_pad_whole_piece_seeding)
|
|||||||
|
|
||||||
TEST_CHECK(!p->is_seeding());
|
TEST_CHECK(!p->is_seeding());
|
||||||
|
|
||||||
p->mark_as_finished({piece_index_t{1}, 0}, NULL);
|
p->mark_as_finished({piece_index_t{1}, 0}, nullptr);
|
||||||
p->mark_as_finished({piece_index_t{1}, 1}, NULL);
|
p->mark_as_finished({piece_index_t{1}, 1}, nullptr);
|
||||||
p->mark_as_finished({piece_index_t{1}, 2}, NULL);
|
p->mark_as_finished({piece_index_t{1}, 2}, nullptr);
|
||||||
p->mark_as_finished({piece_index_t{1}, 3}, NULL);
|
p->mark_as_finished({piece_index_t{1}, 3}, nullptr);
|
||||||
|
|
||||||
TEST_CHECK(!p->is_seeding());
|
TEST_CHECK(!p->is_seeding());
|
||||||
p->piece_passed(piece_index_t{1});
|
p->piece_passed(piece_index_t{1});
|
||||||
|
@ -91,8 +91,8 @@ void test_remove_torrent(remove_flags_t const remove_options
|
|||||||
wait_for_listen(ses2, "ses2");
|
wait_for_listen(ses2, "ses2");
|
||||||
|
|
||||||
// test using piece sizes smaller than 16kB
|
// test using piece sizes smaller than 16kB
|
||||||
std::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, 0
|
std::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, nullptr
|
||||||
, true, false, true, "_remove", 8 * 1024, &t, false, 0);
|
, true, false, true, "_remove", 8 * 1024, &t, false, nullptr);
|
||||||
|
|
||||||
if (test == partial_download)
|
if (test == partial_download)
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ int main(int argc, char* argv[])
|
|||||||
FILE* reads_elev_file = std::fopen("reads_elevator.log", "w+");
|
FILE* reads_elev_file = std::fopen("reads_elevator.log", "w+");
|
||||||
|
|
||||||
|
|
||||||
typedef std::map<std::uint32_t, file_op> op_map;
|
using op_map = std::map<std::uint32_t, file_op>;
|
||||||
op_map outstanding_ops;
|
op_map outstanding_ops;
|
||||||
|
|
||||||
std::uint64_t first_timestamp = 0;
|
std::uint64_t first_timestamp = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user