forked from premiere/premiere-libtorrent
modernize-use-nullptr (#894)
This commit is contained in:
parent
5be93752de
commit
770935cd46
|
@ -133,7 +133,7 @@ retry:
|
|||
FD_ZERO(&set);
|
||||
FD_SET(0, &set);
|
||||
timeval tv = {sleep/ 1000, (sleep % 1000) * 1000 };
|
||||
ret = select(1, &set, 0, 0, &tv);
|
||||
ret = select(1, &set, nullptr, nullptr, &tv);
|
||||
if (ret > 0)
|
||||
{
|
||||
*c = getc(stdin);
|
||||
|
@ -285,7 +285,7 @@ std::string leaf_path(std::string f)
|
|||
char const* altsep = strrchr(first, '\\');
|
||||
if (sep == 0 || altsep > sep) sep = altsep;
|
||||
#endif
|
||||
if (sep == 0) return f;
|
||||
if (sep == nullptr) return f;
|
||||
|
||||
if (sep - first == int(f.size()) - 1)
|
||||
{
|
||||
|
@ -368,7 +368,7 @@ using libtorrent::torrent_status;
|
|||
bool yes(libtorrent::torrent_status const&)
|
||||
{ return true; }
|
||||
|
||||
FILE* g_log_file = 0;
|
||||
FILE* g_log_file = nullptr;
|
||||
|
||||
int peer_index(libtorrent::tcp::endpoint addr, std::vector<libtorrent::peer_info> const& peers)
|
||||
{
|
||||
|
@ -707,7 +707,7 @@ std::vector<std::string> list_dir(std::string path
|
|||
path.resize(path.size()-1);
|
||||
|
||||
DIR* handle = opendir(path.c_str());
|
||||
if (handle == 0)
|
||||
if (handle == nullptr)
|
||||
{
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
return ret;
|
||||
|
@ -717,7 +717,7 @@ std::vector<std::string> list_dir(std::string path
|
|||
dirent* dummy;
|
||||
while (readdir_r(handle, &de, &dummy) == 0)
|
||||
{
|
||||
if (dummy == 0) break;
|
||||
if (dummy == nullptr) break;
|
||||
|
||||
std::string p = de.d_name;
|
||||
if (filter_fun(p))
|
||||
|
@ -807,7 +807,7 @@ void scan_dir(std::string const& dir_path
|
|||
|
||||
char const* timestamp()
|
||||
{
|
||||
time_t t = std::time(0);
|
||||
time_t t = std::time(nullptr);
|
||||
tm* timeinfo = std::localtime(&t);
|
||||
static char str[200];
|
||||
std::strftime(str, 200, "%b %d %X", timeinfo);
|
||||
|
@ -1104,13 +1104,13 @@ void print_piece(libtorrent::partial_piece_info* pp
|
|||
using namespace libtorrent;
|
||||
|
||||
char str[1024];
|
||||
assert(pp == 0 || cs == 0 || cs->piece == pp->piece_index);
|
||||
assert(pp == nullptr || cs == nullptr || cs->piece == pp->piece_index);
|
||||
int piece = pp ? pp->piece_index : cs->piece;
|
||||
int num_blocks = pp ? pp->blocks_in_piece : int(cs->blocks.size());
|
||||
|
||||
std::snprintf(str, sizeof(str), "%5d:[", piece);
|
||||
out += str;
|
||||
char const* last_color = 0;
|
||||
char const* last_color = nullptr;
|
||||
for (int j = 0; j < num_blocks; ++j)
|
||||
{
|
||||
int index = pp ? peer_index(pp->blocks[j].peer(), peers) % 36 : -1;
|
||||
|
@ -1121,7 +1121,7 @@ void print_piece(libtorrent::partial_piece_info* pp
|
|||
|
||||
char const* color = "";
|
||||
|
||||
if (pp == 0)
|
||||
if (pp == nullptr)
|
||||
{
|
||||
color = cs->blocks[j] ? esc("34;7") : esc("0");
|
||||
chr = ' ';
|
||||
|
@ -1142,7 +1142,7 @@ void print_piece(libtorrent::partial_piece_info* pp
|
|||
else if (pp->blocks[j].state == block_info::requested) color = snubbed ? esc("35;7") : esc("0");
|
||||
else { color = esc("0"); chr = ' '; }
|
||||
}
|
||||
if (last_color == 0 || std::strcmp(last_color, color) != 0)
|
||||
if (last_color == nullptr || std::strcmp(last_color, color) != 0)
|
||||
{
|
||||
std::snprintf(str, sizeof(str), "%s%c", color, chr);
|
||||
out += str;
|
||||
|
@ -1940,7 +1940,7 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
if (pos + 3 >= terminal_height) break;
|
||||
|
||||
partial_piece_info* pp = 0;
|
||||
partial_piece_info* pp = nullptr;
|
||||
partial_piece_info tmp;
|
||||
tmp.piece_index = i->piece;
|
||||
std::vector<partial_piece_info>::iterator ppi
|
||||
|
@ -1978,7 +1978,7 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
if (pos + 3 >= terminal_height) break;
|
||||
|
||||
print_piece(&*i, 0, peers, out);
|
||||
print_piece(&*i, nullptr, peers, out);
|
||||
|
||||
int num_blocks = i->blocks_in_piece;
|
||||
p += num_blocks + 8;
|
||||
|
@ -2157,7 +2157,7 @@ int main(int argc, char* argv[])
|
|||
while (num_outstanding_resume_data > 0)
|
||||
{
|
||||
alert const* a = ses.wait_for_alert(seconds(10));
|
||||
if (a == 0) continue;
|
||||
if (a == nullptr) continue;
|
||||
|
||||
std::vector<alert*> alerts;
|
||||
ses.pop_alerts(&alerts);
|
||||
|
|
|
@ -124,7 +124,7 @@ std::string leaf_path(std::string f)
|
|||
char const* altsep = strrchr(first, '\\');
|
||||
if (sep == 0 || altsep > sep) sep = altsep;
|
||||
#endif
|
||||
if (sep == 0) return f;
|
||||
if (sep == nullptr) return f;
|
||||
|
||||
if (sep - first == int(f.size()) - 1)
|
||||
{
|
||||
|
@ -933,7 +933,7 @@ int main(int argc, char* argv[])
|
|||
FILE* output = stdout;
|
||||
if (strcmp("-", torrent_file) != 0)
|
||||
{
|
||||
if( (output = std::fopen(torrent_file, "wb+")) == 0)
|
||||
if( (output = std::fopen(torrent_file, "wb+")) == nullptr)
|
||||
{
|
||||
std::fprintf(stderr, "Could not open file '%s' for writing: %s\n"
|
||||
, torrent_file, std::strerror(errno));
|
||||
|
@ -977,7 +977,7 @@ int main(int argc, char* argv[])
|
|||
// 1 MiB piece size
|
||||
const int piece_size = 1024 * 1024;
|
||||
libtorrent::create_torrent t(fs, piece_size);
|
||||
sha1_hash zero(0);
|
||||
sha1_hash zero(nullptr);
|
||||
for (int k = 0; k < fs.num_pieces(); ++k)
|
||||
t.set_hash(k, zero);
|
||||
|
||||
|
@ -986,7 +986,7 @@ int main(int argc, char* argv[])
|
|||
std::back_insert_iterator<std::vector<char> > out(buf);
|
||||
bencode(out, t.generate());
|
||||
FILE* f = std::fopen(torrent_name, "w+");
|
||||
if (f == 0)
|
||||
if (f == nullptr)
|
||||
{
|
||||
std::fprintf(stderr, "Could not open file '%s' for writing: %s\n"
|
||||
, torrent_name, std::strerror(errno));
|
||||
|
|
|
@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
char const* timestamp()
|
||||
{
|
||||
std::time_t t = std::time(0);
|
||||
std::time_t t = std::time(nullptr);
|
||||
std::tm* timeinfo = std::localtime(&t);
|
||||
static char str[200];
|
||||
std::strftime(str, 200, "%b %d %X", timeinfo);
|
||||
|
@ -78,7 +78,7 @@ int main(int argc, char* argv[])
|
|||
for (;;)
|
||||
{
|
||||
alert const* a = s.wait_for_alert(seconds(5));
|
||||
if (a == 0)
|
||||
if (a == nullptr)
|
||||
{
|
||||
settings_pack p;
|
||||
p.set_bool(settings_pack::enable_upnp, false);
|
||||
|
@ -100,7 +100,7 @@ int main(int argc, char* argv[])
|
|||
for (;;)
|
||||
{
|
||||
alert const* a = s.wait_for_alert(seconds(5));
|
||||
if (a == 0) break;
|
||||
if (a == nullptr) break;
|
||||
std::vector<alert*> alerts;
|
||||
s.pop_alerts(&alerts);
|
||||
for (std::vector<alert*>::iterator i = alerts.begin()
|
||||
|
|
|
@ -705,7 +705,7 @@ boost::shared_ptr<torrent_info> make_torrent(bool priv)
|
|||
ct.add_tracker("http://tracker.com:8080/announce");
|
||||
|
||||
for (int i = 0; i < ct.num_pieces(); ++i)
|
||||
ct.set_hash(i, sha1_hash(0));
|
||||
ct.set_hash(i, sha1_hash(nullptr));
|
||||
|
||||
ct.set_priv(priv);
|
||||
|
||||
|
|
|
@ -1101,7 +1101,7 @@ namespace libtorrent {
|
|||
|
||||
peer_blocked_alert::peer_blocked_alert(aux::stack_allocator& alloc
|
||||
, torrent_handle const& h, tcp::endpoint const& ep, int r)
|
||||
: peer_alert(alloc, h, ep, peer_id(0))
|
||||
: peer_alert(alloc, h, ep, peer_id(nullptr))
|
||||
, reason(r)
|
||||
{}
|
||||
|
||||
|
@ -1233,7 +1233,7 @@ namespace libtorrent {
|
|||
|
||||
lsd_peer_alert::lsd_peer_alert(aux::stack_allocator& alloc, torrent_handle const& h
|
||||
, tcp::endpoint const& i)
|
||||
: peer_alert(alloc, h, i, peer_id(0))
|
||||
: peer_alert(alloc, h, i, peer_id(nullptr))
|
||||
{}
|
||||
|
||||
std::string lsd_peer_alert::message() const
|
||||
|
@ -1588,7 +1588,7 @@ namespace libtorrent {
|
|||
, std::string s
|
||||
, std::uint64_t sequence_number
|
||||
, int n)
|
||||
: target(0)
|
||||
: target(nullptr)
|
||||
, public_key(key)
|
||||
, signature(sig)
|
||||
, salt(s)
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace libtorrent
|
|||
|
||||
void page_aligned_allocator::free(char* block)
|
||||
{
|
||||
if (block == 0) return;
|
||||
if (block == nullptr) return;
|
||||
|
||||
#ifdef TORRENT_DEBUG_BUFFERS
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ std::string demangle(char const* name)
|
|||
// in case this string comes
|
||||
// this is needed on linux
|
||||
char const* start = strchr(name, '(');
|
||||
if (start != 0)
|
||||
if (start != nullptr)
|
||||
{
|
||||
++start;
|
||||
}
|
||||
|
@ -77,10 +77,10 @@ std::string demangle(char const* name)
|
|||
{
|
||||
// this is needed on macos x
|
||||
start = strstr(name, "0x");
|
||||
if (start != 0)
|
||||
if (start != nullptr)
|
||||
{
|
||||
start = strchr(start, ' ');
|
||||
if (start != 0) ++start;
|
||||
if (start != nullptr) ++start;
|
||||
else start = name;
|
||||
}
|
||||
else start = name;
|
||||
|
@ -90,13 +90,13 @@ std::string demangle(char const* name)
|
|||
if (end) while (*(end-1) == ' ') --end;
|
||||
|
||||
std::string in;
|
||||
if (end == 0) in.assign(start);
|
||||
if (end == nullptr) in.assign(start);
|
||||
else in.assign(start, end);
|
||||
|
||||
size_t len;
|
||||
int status;
|
||||
char* unmangled = ::abi::__cxa_demangle(in.c_str(), 0, &len, &status);
|
||||
if (unmangled == 0) return in;
|
||||
char* unmangled = ::abi::__cxa_demangle(in.c_str(), nullptr, &len, &status);
|
||||
if (unmangled == nullptr) return in;
|
||||
std::string ret(unmangled);
|
||||
free(unmangled);
|
||||
return ret;
|
||||
|
|
|
@ -211,7 +211,7 @@ namespace libtorrent
|
|||
|
||||
|
||||
bdecode_node::bdecode_node()
|
||||
: m_root_tokens(0)
|
||||
: m_root_tokens(nullptr)
|
||||
, m_buffer(nullptr)
|
||||
, m_buffer_size(0)
|
||||
, m_token_idx(-1)
|
||||
|
|
|
@ -304,7 +304,7 @@ static_assert(sizeof(job_action_name)/sizeof(job_action_name[0])
|
|||
|
||||
cached_piece_entry::cached_piece_entry()
|
||||
: storage()
|
||||
, hash(0)
|
||||
, hash(nullptr)
|
||||
, last_requester(nullptr)
|
||||
, blocks()
|
||||
, expire(min_time())
|
||||
|
@ -337,7 +337,7 @@ cached_piece_entry::~cached_piece_entry()
|
|||
#if TORRENT_USE_ASSERTS
|
||||
for (int i = 0; i < blocks_in_piece; ++i)
|
||||
{
|
||||
TORRENT_ASSERT(blocks[i].buf == 0);
|
||||
TORRENT_ASSERT(blocks[i].buf == nullptr);
|
||||
TORRENT_ASSERT(!blocks[i].pending);
|
||||
TORRENT_ASSERT(blocks[i].refcount == 0);
|
||||
TORRENT_ASSERT(blocks[i].hashing_count == 0);
|
||||
|
@ -369,7 +369,7 @@ int block_cache::try_read(disk_io_job* j, bool expect_no_fail)
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
|
||||
TORRENT_ASSERT(j->buffer.disk_block == 0);
|
||||
TORRENT_ASSERT(j->buffer.disk_block == nullptr);
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
// we're not allowed to add dirty blocks
|
||||
|
@ -387,7 +387,7 @@ int block_cache::try_read(disk_io_job* j, bool expect_no_fail)
|
|||
// if the piece cannot be found in the cache,
|
||||
// it's a cache miss
|
||||
TORRENT_ASSERT(!expect_no_fail || p != nullptr);
|
||||
if (p == 0) return -1;
|
||||
if (p == nullptr) return -1;
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
p->piece_log.push_back(piece_log_t(j->action, j->d.io.offset / 0x4000));
|
||||
|
@ -508,7 +508,7 @@ void block_cache::update_cache_state(cached_piece_entry* p)
|
|||
{
|
||||
int state = p->cache_state;
|
||||
int desired_state = p->cache_state;
|
||||
if (p->num_dirty > 0 || p->hash != 0)
|
||||
if (p->num_dirty > 0 || p->hash != nullptr)
|
||||
desired_state = cached_piece_entry::write_lru;
|
||||
else if (p->cache_state == cached_piece_entry::write_lru)
|
||||
desired_state = cached_piece_entry::read_lru1;
|
||||
|
@ -560,7 +560,7 @@ void block_cache::try_evict_one_volatile()
|
|||
{
|
||||
#if TORRENT_USE_INVARIANT_CHECKS
|
||||
for (int j = 0; j < pe->blocks_in_piece; ++j)
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe);
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == nullptr, pe);
|
||||
#endif
|
||||
TORRENT_PIECE_ASSERT(pe->refcount == 0, pe);
|
||||
move_to_ghost(pe);
|
||||
|
@ -587,7 +587,7 @@ void block_cache::try_evict_one_volatile()
|
|||
TORRENT_PIECE_ASSERT(b.dirty == false, pe);
|
||||
TORRENT_PIECE_ASSERT(b.pending == false, pe);
|
||||
|
||||
if (b.buf == 0 || b.refcount > 0 || b.dirty || b.pending) continue;
|
||||
if (b.buf == nullptr || b.refcount > 0 || b.dirty || b.pending) continue;
|
||||
|
||||
to_delete[num_to_delete++] = b.buf;
|
||||
b.buf = nullptr;
|
||||
|
@ -603,7 +603,7 @@ void block_cache::try_evict_one_volatile()
|
|||
{
|
||||
#if TORRENT_USE_INVARIANT_CHECKS
|
||||
for (int j = 0; j < pe->blocks_in_piece; ++j)
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe);
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == nullptr, pe);
|
||||
#endif
|
||||
move_to_ghost(pe);
|
||||
}
|
||||
|
@ -632,7 +632,7 @@ cached_piece_entry* block_cache::allocate_piece(disk_io_job const* j, int cache_
|
|||
&& cache_state != cached_piece_entry::read_lru2_ghost);
|
||||
|
||||
cached_piece_entry* p = find_piece(j);
|
||||
if (p == 0)
|
||||
if (p == nullptr)
|
||||
{
|
||||
int const piece_size = j->storage->files()->piece_size(j->piece);
|
||||
int const blocks_in_piece = (piece_size + block_size() - 1) / block_size();
|
||||
|
@ -761,7 +761,7 @@ cached_piece_entry* block_cache::add_dirty_block(disk_io_job* j)
|
|||
|
||||
cached_piece_entry* pe = allocate_piece(j, cached_piece_entry::write_lru);
|
||||
TORRENT_ASSERT(pe);
|
||||
if (pe == 0) return pe;
|
||||
if (pe == nullptr) return pe;
|
||||
|
||||
TORRENT_PIECE_ASSERT(pe->in_use, pe);
|
||||
|
||||
|
@ -792,7 +792,7 @@ cached_piece_entry* block_cache::add_dirty_block(disk_io_job* j)
|
|||
// hash checking
|
||||
// we might also have a previous dirty block which
|
||||
// we're still waiting for to be written
|
||||
if (b.buf != 0 && b.buf != j->buffer.disk_block)
|
||||
if (b.buf != nullptr && b.buf != j->buffer.disk_block)
|
||||
{
|
||||
TORRENT_PIECE_ASSERT(b.refcount == 0 && !b.pending, pe);
|
||||
free_block(pe, block);
|
||||
|
@ -805,7 +805,7 @@ cached_piece_entry* block_cache::add_dirty_block(disk_io_job* j)
|
|||
++pe->num_blocks;
|
||||
++pe->num_dirty;
|
||||
++m_write_cache_size;
|
||||
j->buffer.disk_block = 0;
|
||||
j->buffer.disk_block = nullptr;
|
||||
TORRENT_PIECE_ASSERT(j->piece == pe->piece, pe);
|
||||
TORRENT_PIECE_ASSERT(j->flags & disk_io_job::in_progress, pe);
|
||||
TORRENT_PIECE_ASSERT(j->piece == pe->piece, pe);
|
||||
|
@ -860,7 +860,7 @@ std::pair<block_cache::iterator, block_cache::iterator> block_cache::all_pieces(
|
|||
|
||||
void block_cache::free_block(cached_piece_entry* pe, int block)
|
||||
{
|
||||
TORRENT_ASSERT(pe != 0);
|
||||
TORRENT_ASSERT(pe != nullptr);
|
||||
TORRENT_PIECE_ASSERT(pe->in_use, pe);
|
||||
TORRENT_PIECE_ASSERT(block < pe->blocks_in_piece, pe);
|
||||
TORRENT_PIECE_ASSERT(block >= 0, pe);
|
||||
|
@ -905,9 +905,9 @@ bool block_cache::evict_piece(cached_piece_entry* pe, tailqueue<disk_io_job>& jo
|
|||
int num_to_delete = 0;
|
||||
for (int i = 0; i < pe->blocks_in_piece; ++i)
|
||||
{
|
||||
if (pe->blocks[i].buf == 0 || pe->blocks[i].refcount > 0) continue;
|
||||
if (pe->blocks[i].buf == nullptr || pe->blocks[i].refcount > 0) continue;
|
||||
TORRENT_PIECE_ASSERT(!pe->blocks[i].pending, pe);
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[i].buf != 0, pe);
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[i].buf != nullptr, pe);
|
||||
TORRENT_PIECE_ASSERT(num_to_delete < pe->blocks_in_piece, pe);
|
||||
to_delete[num_to_delete++] = pe->blocks[i].buf;
|
||||
pe->blocks[i].buf = nullptr;
|
||||
|
@ -1077,7 +1077,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore)
|
|||
{
|
||||
#if TORRENT_USE_INVARIANT_CHECKS
|
||||
for (int j = 0; j < pe->blocks_in_piece; ++j)
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe);
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == nullptr, pe);
|
||||
#endif
|
||||
TORRENT_PIECE_ASSERT(pe->refcount == 0, pe);
|
||||
move_to_ghost(pe);
|
||||
|
@ -1096,7 +1096,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore)
|
|||
{
|
||||
cached_block_entry& b = pe->blocks[j];
|
||||
|
||||
if (b.buf == 0 || b.refcount > 0 || b.dirty || b.pending) continue;
|
||||
if (b.buf == nullptr || b.refcount > 0 || b.dirty || b.pending) continue;
|
||||
|
||||
to_delete[num_to_delete++] = b.buf;
|
||||
b.buf = nullptr;
|
||||
|
@ -1117,7 +1117,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore)
|
|||
{
|
||||
#if TORRENT_USE_INVARIANT_CHECKS
|
||||
for (int j = 0; j < pe->blocks_in_piece; ++j)
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe);
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == nullptr, pe);
|
||||
#endif
|
||||
move_to_ghost(pe);
|
||||
}
|
||||
|
@ -1150,7 +1150,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore)
|
|||
{
|
||||
#if TORRENT_USE_INVARIANT_CHECKS
|
||||
for (int j = 0; j < pe->blocks_in_piece; ++j)
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe);
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == nullptr, pe);
|
||||
#endif
|
||||
TORRENT_PIECE_ASSERT(pe->refcount == 0, pe);
|
||||
erase_piece(pe);
|
||||
|
@ -1175,7 +1175,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore)
|
|||
{
|
||||
cached_block_entry& b = pe->blocks[j];
|
||||
|
||||
if (b.buf == 0 || b.refcount > 0 || b.dirty || b.pending) continue;
|
||||
if (b.buf == nullptr || b.refcount > 0 || b.dirty || b.pending) continue;
|
||||
|
||||
to_delete[num_to_delete++] = b.buf;
|
||||
b.buf = nullptr;
|
||||
|
@ -1196,7 +1196,7 @@ int block_cache::try_evict_blocks(int num, cached_piece_entry* ignore)
|
|||
{
|
||||
#if TORRENT_USE_INVARIANT_CHECKS
|
||||
for (int j = 0; j < pe->blocks_in_piece; ++j)
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == 0, pe);
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[j].buf == nullptr, pe);
|
||||
#endif
|
||||
erase_piece(pe);
|
||||
}
|
||||
|
@ -1486,7 +1486,7 @@ void block_cache::free_piece(cached_piece_entry* pe)
|
|||
int removed_clean = 0;
|
||||
for (int i = 0; i < pe->blocks_in_piece; ++i)
|
||||
{
|
||||
if (pe->blocks[i].buf == 0) continue;
|
||||
if (pe->blocks[i].buf == nullptr) continue;
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[i].pending == false, pe);
|
||||
TORRENT_PIECE_ASSERT(pe->blocks[i].refcount == 0, pe);
|
||||
TORRENT_PIECE_ASSERT(num_to_delete < pe->blocks_in_piece, pe);
|
||||
|
@ -1528,7 +1528,7 @@ int block_cache::drain_piece_bufs(cached_piece_entry& p, std::vector<char*>& buf
|
|||
int removed_clean = 0;
|
||||
for (int i = 0; i < blocks_in_piece; ++i)
|
||||
{
|
||||
if (p.blocks[i].buf == 0) continue;
|
||||
if (p.blocks[i].buf == nullptr) continue;
|
||||
TORRENT_PIECE_ASSERT(p.blocks[i].refcount == 0, &p);
|
||||
buf.push_back(p.blocks[i].buf);
|
||||
++ret;
|
||||
|
@ -1752,7 +1752,7 @@ int block_cache::copy_from_piece(cached_piece_entry* const pe
|
|||
INVARIANT_CHECK;
|
||||
TORRENT_UNUSED(expect_no_fail);
|
||||
|
||||
TORRENT_PIECE_ASSERT(j->buffer.disk_block == 0, pe);
|
||||
TORRENT_PIECE_ASSERT(j->buffer.disk_block == nullptr, pe);
|
||||
TORRENT_PIECE_ASSERT(pe->in_use, pe);
|
||||
|
||||
// copy from the cache and update the last use timestamp
|
||||
|
@ -1811,7 +1811,7 @@ int block_cache::copy_from_piece(cached_piece_entry* const pe
|
|||
}
|
||||
|
||||
j->buffer.disk_block = allocate_buffer("send buffer");
|
||||
if (j->buffer.disk_block == 0) return -2;
|
||||
if (j->buffer.disk_block == nullptr) return -2;
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
|
|
|
@ -1493,7 +1493,7 @@ namespace libtorrent
|
|||
// the peer at 'ep'. We need to find which of
|
||||
// our connections points to that endpoint
|
||||
bt_peer_connection* p = t->find_peer(ep);
|
||||
if (p == 0)
|
||||
if (p == nullptr)
|
||||
{
|
||||
// we're not connected to this peer
|
||||
write_holepunch_msg(hp_failed, ep, hp_not_connected);
|
||||
|
@ -1517,7 +1517,7 @@ namespace libtorrent
|
|||
{
|
||||
// add or find the peer with this endpoint
|
||||
torrent_peer* p = t->add_peer(ep, peer_info::pex);
|
||||
if (p == 0 || p->connection)
|
||||
if (p == nullptr || p->connection)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(peer_log_alert::incoming_message, "HOLEPUNCH"
|
||||
|
@ -1789,7 +1789,7 @@ namespace libtorrent
|
|||
|
||||
// there is supposed to be a remote listen port
|
||||
int listen_port = int(root.dict_find_int_value("p"));
|
||||
if (listen_port > 0 && peer_info_struct() != 0)
|
||||
if (listen_port > 0 && peer_info_struct() != nullptr)
|
||||
{
|
||||
t->update_peer_port(listen_port, peer_info_struct(), peer_info::incoming);
|
||||
received_listen_port();
|
||||
|
@ -2111,7 +2111,7 @@ namespace libtorrent
|
|||
const int packet_size = (num_pieces + 7) / 8 + 5;
|
||||
|
||||
std::uint8_t* msg = TORRENT_ALLOCA(std::uint8_t, packet_size);
|
||||
if (msg == 0) return; // out of memory
|
||||
if (msg == nullptr) return; // out of memory
|
||||
unsigned char* ptr = msg;
|
||||
|
||||
detail::write_int32(packet_size - 4, ptr);
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace libtorrent
|
|||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
char* insert = allocate_appendix(s);
|
||||
if (insert == 0) return 0;
|
||||
if (insert == nullptr) return nullptr;
|
||||
memcpy(insert, buf, s);
|
||||
return insert;
|
||||
}
|
||||
|
@ -133,10 +133,10 @@ namespace libtorrent
|
|||
char* chained_buffer::allocate_appendix(int s)
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
if (m_vec.empty()) return 0;
|
||||
if (m_vec.empty()) return nullptr;
|
||||
buffer_t& b = m_vec.back();
|
||||
char* insert = b.start + b.used_size;
|
||||
if (insert + s > b.buf + b.size) return 0;
|
||||
if (insert + s > b.buf + b.size) return nullptr;
|
||||
b.used_size += s;
|
||||
m_bytes += s;
|
||||
TORRENT_ASSERT(m_bytes <= m_capacity);
|
||||
|
|
|
@ -275,7 +275,7 @@ namespace libtorrent
|
|||
// dummy torrent object pointer
|
||||
boost::shared_ptr<char> dummy;
|
||||
counters cnt;
|
||||
disk_io_thread disk_thread(ios, cnt, 0);
|
||||
disk_io_thread disk_thread(ios, cnt, nullptr);
|
||||
disk_thread.set_num_threads(1);
|
||||
|
||||
storage_params params;
|
||||
|
@ -320,7 +320,7 @@ namespace libtorrent
|
|||
create_torrent::create_torrent(file_storage& fs, int piece_size
|
||||
, int pad_file_limit, int flags, int alignment)
|
||||
: m_files(fs)
|
||||
, m_creation_date(time(0))
|
||||
, m_creation_date(time(nullptr))
|
||||
, m_multifile(fs.num_files() > 1)
|
||||
, m_private(false)
|
||||
, m_merkle_torrent((flags & merkle) != 0)
|
||||
|
@ -379,7 +379,7 @@ namespace libtorrent
|
|||
|
||||
create_torrent::create_torrent(torrent_info const& ti)
|
||||
: m_files(const_cast<file_storage&>(ti.files()))
|
||||
, m_creation_date(time(0))
|
||||
, m_creation_date(time(nullptr))
|
||||
, m_multifile(ti.num_files() > 1)
|
||||
, m_private(ti.priv())
|
||||
, m_merkle_torrent(ti.is_merkle_torrent())
|
||||
|
@ -569,7 +569,7 @@ namespace libtorrent
|
|||
entry& sympath_e = info["symlink path"];
|
||||
|
||||
std::string split = split_path(m_files.symlink(0));
|
||||
for (char const* e = split.c_str(); e != 0; e = next_path_element(e))
|
||||
for (char const* e = split.c_str(); e != nullptr; e = next_path_element(e))
|
||||
sympath_e.list().push_back(entry(e));
|
||||
}
|
||||
if (!m_filehashes.empty())
|
||||
|
@ -598,7 +598,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(split.c_str() == m_files.name());
|
||||
|
||||
for (char const* e = next_path_element(split.c_str());
|
||||
e != 0; e = next_path_element(e))
|
||||
e != nullptr; e = next_path_element(e))
|
||||
path_e.list().push_back(entry(e));
|
||||
}
|
||||
|
||||
|
@ -618,7 +618,7 @@ namespace libtorrent
|
|||
entry& sympath_e = file_e["symlink path"];
|
||||
|
||||
std::string split = split_path(m_files.symlink(i));
|
||||
for (char const* e = split.c_str(); e != 0; e = next_path_element(e))
|
||||
for (char const* e = split.c_str(); e != nullptr; e = next_path_element(e))
|
||||
sympath_e.list().push_back(entry(e));
|
||||
}
|
||||
if (!m_filehashes.empty() && m_filehashes[i] != sha1_hash())
|
||||
|
@ -639,7 +639,7 @@ namespace libtorrent
|
|||
int num_pieces = int(m_piece_hash.size());
|
||||
for (int i = 0; i < num_pieces; ++i)
|
||||
m_merkle_tree[first_leaf + i] = m_piece_hash[i];
|
||||
sha1_hash filler(0);
|
||||
sha1_hash filler(nullptr);
|
||||
for (int i = num_pieces; i < num_leafs; ++i)
|
||||
m_merkle_tree[first_leaf + i] = filler;
|
||||
|
||||
|
@ -738,13 +738,13 @@ namespace libtorrent
|
|||
|
||||
void create_torrent::set_comment(char const* str)
|
||||
{
|
||||
if (str == 0) m_comment.clear();
|
||||
if (str == nullptr) m_comment.clear();
|
||||
else m_comment = str;
|
||||
}
|
||||
|
||||
void create_torrent::set_creator(char const* str)
|
||||
{
|
||||
if (str == 0) m_created_by.clear();
|
||||
if (str == nullptr) m_created_by.clear();
|
||||
else m_created_by = str;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace libtorrent
|
|||
, m_cache_buffer_chunk_size(0)
|
||||
#if TORRENT_HAVE_MMAP
|
||||
, m_cache_fd(-1)
|
||||
, m_cache_pool(0)
|
||||
, m_cache_pool(nullptr)
|
||||
#endif
|
||||
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
|
||||
, m_using_pool_allocator(false)
|
||||
|
@ -115,7 +115,7 @@ namespace libtorrent
|
|||
if (m_cache_pool)
|
||||
{
|
||||
munmap(m_cache_pool, std::uint64_t(m_max_use) * 0x4000);
|
||||
m_cache_pool = 0;
|
||||
m_cache_pool = nullptr;
|
||||
// attempt to make MacOS not flush this to disk, making close()
|
||||
// block for a long time
|
||||
int ignore = ftruncate(m_cache_fd, 0);
|
||||
|
@ -273,7 +273,7 @@ namespace libtorrent
|
|||
m_exceeded_max_size = true;
|
||||
m_trigger_cache_trim();
|
||||
}
|
||||
if (m_free_list.empty()) return 0;
|
||||
if (m_free_list.empty()) return nullptr;
|
||||
std::uint64_t slot_index = m_free_list.back();
|
||||
m_free_list.pop_back();
|
||||
ret = m_cache_pool + (slot_index * 0x4000);
|
||||
|
@ -307,7 +307,7 @@ namespace libtorrent
|
|||
{
|
||||
m_exceeded_max_size = true;
|
||||
m_trigger_cache_trim();
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ namespace libtorrent
|
|||
// cache, or if we're just about to turn it off
|
||||
if (
|
||||
#if TORRENT_HAVE_MMAP
|
||||
m_cache_pool == 0 ||
|
||||
m_cache_pool == nullptr ||
|
||||
#endif
|
||||
sett.get_str(settings_pack::mmap_cache).empty())
|
||||
{
|
||||
|
@ -459,7 +459,7 @@ namespace libtorrent
|
|||
{
|
||||
TORRENT_ASSERT(m_in_use == 0);
|
||||
munmap(m_cache_pool, std::uint64_t(m_max_use) * 0x4000);
|
||||
m_cache_pool = 0;
|
||||
m_cache_pool = nullptr;
|
||||
// attempt to make MacOS not flush this to disk, making close()
|
||||
// block for a long time
|
||||
int ignore = ftruncate(m_cache_fd, 0);
|
||||
|
@ -468,7 +468,7 @@ namespace libtorrent
|
|||
m_cache_fd = -1;
|
||||
std::vector<int>().swap(m_free_list);
|
||||
}
|
||||
else if (m_cache_pool == 0 && !sett.get_str(settings_pack::mmap_cache).empty())
|
||||
else if (m_cache_pool == nullptr && !sett.get_str(settings_pack::mmap_cache).empty())
|
||||
{
|
||||
// O_TRUNC here is because we don't actually care about what's
|
||||
// in the file now, there's no need to ever read that into RAM
|
||||
|
@ -488,19 +488,19 @@ namespace libtorrent
|
|||
if (ftruncate(m_cache_fd, std::uint64_t(m_max_use) * 0x4000) < 0)
|
||||
{
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
m_cache_pool = 0;
|
||||
m_cache_pool = nullptr;
|
||||
close(m_cache_fd);
|
||||
m_cache_fd = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
m_cache_pool = static_cast<char*>(mmap(0, std::uint64_t(m_max_use) * 0x4000, PROT_READ | PROT_WRITE
|
||||
m_cache_pool = static_cast<char*>(mmap(nullptr, std::uint64_t(m_max_use) * 0x4000, PROT_READ | PROT_WRITE
|
||||
, MAP_SHARED | MAP_NOCACHE, m_cache_fd, 0));
|
||||
if (intptr_t(m_cache_pool) == -1)
|
||||
{
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
|
||||
m_cache_pool = 0;
|
||||
m_cache_pool = nullptr;
|
||||
// attempt to make MacOS not flush this to disk, making close()
|
||||
// block for a long time
|
||||
int ignore = ftruncate(m_cache_fd, 0);
|
||||
|
|
|
@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
namespace libtorrent
|
||||
{
|
||||
disk_io_job::disk_io_job()
|
||||
: requester(0)
|
||||
: requester(nullptr)
|
||||
, piece(0)
|
||||
, action(read)
|
||||
, ret(0)
|
||||
|
@ -50,10 +50,10 @@ namespace libtorrent
|
|||
, blocked(false)
|
||||
#endif
|
||||
{
|
||||
buffer.disk_block = 0;
|
||||
buffer.disk_block = nullptr;
|
||||
d.io.offset = 0;
|
||||
d.io.buffer_size = 0;
|
||||
d.io.ref.storage = 0;
|
||||
d.io.ref.storage = nullptr;
|
||||
d.io.ref.piece = 0;
|
||||
d.io.ref.block = 0;
|
||||
}
|
||||
|
|
|
@ -270,7 +270,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(m_magic == 0x1337);
|
||||
TORRENT_ASSERT(l.owns_lock());
|
||||
TORRENT_ASSERT(cont_block > 0);
|
||||
if (p->hash == 0 && !p->hashing_done)
|
||||
if (p->hash == nullptr && !p->hashing_done)
|
||||
{
|
||||
DLOG("try_flush_hashed: (%d) no hash\n", int(p->piece));
|
||||
return 0;
|
||||
|
@ -1057,7 +1057,7 @@ namespace libtorrent
|
|||
void disk_io_thread::perform_job(disk_io_job* j, jobqueue_t& completed_jobs)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_ASSERT(j->next == 0);
|
||||
TORRENT_ASSERT(j->next == nullptr);
|
||||
TORRENT_ASSERT((j->flags & disk_io_job::in_progress) || !j->storage);
|
||||
|
||||
#if DEBUG_DISK_THREAD
|
||||
|
@ -1079,7 +1079,7 @@ namespace libtorrent
|
|||
// call. Each disk thread could hold its most recent understanding of the settings
|
||||
// in a shared_ptr, and update it every time it wakes up from a job. That way
|
||||
// each access to the settings won't require a std::mutex to be held.
|
||||
if (storage && storage->get_storage_impl()->m_settings == 0)
|
||||
if (storage && storage->get_storage_impl()->m_settings == nullptr)
|
||||
storage->get_storage_impl()->m_settings = &m_settings;
|
||||
|
||||
TORRENT_ASSERT(j->action < sizeof(job_functions)/sizeof(job_functions[0]));
|
||||
|
@ -1147,7 +1147,7 @@ namespace libtorrent
|
|||
int disk_io_thread::do_uncached_read(disk_io_job* j)
|
||||
{
|
||||
j->buffer.disk_block = m_disk_cache.allocate_buffer("send buffer");
|
||||
if (j->buffer.disk_block == 0)
|
||||
if (j->buffer.disk_block == nullptr)
|
||||
{
|
||||
j->error.ec = error::no_memory;
|
||||
j->error.operation = storage_error::alloc_cache_piece;
|
||||
|
@ -1447,7 +1447,7 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
if (!pe->hashing_done
|
||||
&& pe->hash == 0
|
||||
&& pe->hash == nullptr
|
||||
&& !m_settings.get_bool(settings_pack::disable_hash_checks))
|
||||
{
|
||||
pe->hash = new partial_hash;
|
||||
|
@ -1500,7 +1500,7 @@ namespace libtorrent
|
|||
j->piece = r.piece;
|
||||
j->d.io.offset = r.start;
|
||||
j->d.io.buffer_size = r.length;
|
||||
j->buffer.disk_block = 0;
|
||||
j->buffer.disk_block = nullptr;
|
||||
j->flags = flags;
|
||||
j->requester = requester;
|
||||
j->callback = std::move(handler);
|
||||
|
@ -2055,7 +2055,7 @@ namespace libtorrent
|
|||
std::unique_lock<std::mutex> l(m_cache_mutex);
|
||||
|
||||
cached_piece_entry* pe = m_disk_cache.find_piece(storage, index);
|
||||
if (pe == 0) return;
|
||||
if (pe == nullptr) return;
|
||||
TORRENT_PIECE_ASSERT(pe->hashing == false, pe);
|
||||
pe->hashing_done = 0;
|
||||
delete pe->hash;
|
||||
|
@ -2093,7 +2093,7 @@ namespace libtorrent
|
|||
for (int i = cursor; i < pe->blocks_in_piece; ++i)
|
||||
{
|
||||
cached_block_entry& bl = pe->blocks[i];
|
||||
if (bl.buf == 0) break;
|
||||
if (bl.buf == nullptr) break;
|
||||
|
||||
// if we fail to lock the block, it' no longer in the cache
|
||||
if (m_disk_cache.inc_block_refcount(pe, i, block_cache::ref_hashing) == false)
|
||||
|
@ -2563,7 +2563,7 @@ namespace libtorrent
|
|||
int disk_io_thread::do_cache_piece(disk_io_job* j, jobqueue_t& /* completed_jobs */ )
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_ASSERT(j->buffer.disk_block == 0);
|
||||
TORRENT_ASSERT(j->buffer.disk_block == nullptr);
|
||||
|
||||
if (m_settings.get_int(settings_pack::cache_size) == 0
|
||||
|| m_settings.get_bool(settings_pack::use_read_cache) == false)
|
||||
|
@ -2678,7 +2678,7 @@ namespace libtorrent
|
|||
info.storage = i->storage.get();
|
||||
info.last_use = i->expire;
|
||||
info.need_readback = i->need_readback;
|
||||
info.next_to_hash = i->hash == 0 ? -1 : (i->hash->offset + block_size - 1) / block_size;
|
||||
info.next_to_hash = i->hash == nullptr ? -1 : (i->hash->offset + block_size - 1) / block_size;
|
||||
info.kind = i->cache_state == cached_piece_entry::write_lru
|
||||
? cached_piece_info::write_cache
|
||||
: i->cache_state == cached_piece_entry::volatile_read_lru
|
||||
|
@ -2687,7 +2687,7 @@ namespace libtorrent
|
|||
int blocks_in_piece = i->blocks_in_piece;
|
||||
info.blocks.resize(blocks_in_piece);
|
||||
for (int b = 0; b < blocks_in_piece; ++b)
|
||||
info.blocks[b] = i->blocks[b].buf != 0;
|
||||
info.blocks[b] = i->blocks[b].buf != nullptr;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -2855,7 +2855,7 @@ namespace libtorrent
|
|||
|
||||
if (!pe->hashing_done)
|
||||
{
|
||||
if (pe->hash == 0 && !m_settings.get_bool(settings_pack::disable_hash_checks))
|
||||
if (pe->hash == nullptr && !m_settings.get_bool(settings_pack::disable_hash_checks))
|
||||
{
|
||||
pe->hash = new partial_hash;
|
||||
m_disk_cache.update_cache_state(pe);
|
||||
|
@ -2934,7 +2934,7 @@ namespace libtorrent
|
|||
std::unique_lock<std::mutex> l(m_cache_mutex);
|
||||
|
||||
cached_piece_entry* pe = m_disk_cache.find_piece(j);
|
||||
if (pe == 0) return 0;
|
||||
if (pe == nullptr) return 0;
|
||||
TORRENT_PIECE_ASSERT(pe->hashing == false, pe);
|
||||
pe->hashing_done = 0;
|
||||
delete pe->hash;
|
||||
|
@ -3211,7 +3211,7 @@ namespace libtorrent
|
|||
|
||||
for (;;)
|
||||
{
|
||||
disk_io_job* j = 0;
|
||||
disk_io_job* j = nullptr;
|
||||
if (type == generic_thread)
|
||||
{
|
||||
bool const should_exit = wait_for_job(m_generic_io_jobs, m_generic_threads, l);
|
||||
|
@ -3486,7 +3486,7 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
if (!pe->hashing_done
|
||||
&& pe->hash == 0
|
||||
&& pe->hash == nullptr
|
||||
&& !m_settings.get_bool(settings_pack::disable_hash_checks))
|
||||
{
|
||||
pe->hash = new partial_hash;
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace libtorrent
|
|||
std::unique_lock<std::mutex> l(m_job_mutex);
|
||||
disk_io_job* ptr = static_cast<disk_io_job*>(m_job_pool.malloc());
|
||||
m_job_pool.set_next_size(100);
|
||||
if (ptr == 0) return 0;
|
||||
if (ptr == nullptr) return nullptr;
|
||||
++m_jobs_in_use;
|
||||
if (type == disk_io_job::read) ++m_read_jobs;
|
||||
else if (type == disk_io_job::write) ++m_write_jobs;
|
||||
|
@ -71,7 +71,7 @@ namespace libtorrent
|
|||
void disk_job_pool::free_job(disk_io_job* j)
|
||||
{
|
||||
TORRENT_ASSERT(j);
|
||||
if (j == 0) return;
|
||||
if (j == nullptr) return;
|
||||
#if TORRENT_USE_ASSERTS
|
||||
TORRENT_ASSERT(j->in_use);
|
||||
j->in_use = false;
|
||||
|
|
|
@ -114,28 +114,28 @@ namespace libtorrent
|
|||
entry* entry::find_key(char const* key)
|
||||
{
|
||||
dictionary_type::iterator i = dict().find(key);
|
||||
if (i == dict().end()) return 0;
|
||||
if (i == dict().end()) return nullptr;
|
||||
return &i->second;
|
||||
}
|
||||
|
||||
entry const* entry::find_key(char const* key) const
|
||||
{
|
||||
dictionary_type::const_iterator i = dict().find(key);
|
||||
if (i == dict().end()) return 0;
|
||||
if (i == dict().end()) return nullptr;
|
||||
return &i->second;
|
||||
}
|
||||
|
||||
entry* entry::find_key(std::string const& key)
|
||||
{
|
||||
dictionary_type::iterator i = dict().find(key);
|
||||
if (i == dict().end()) return 0;
|
||||
if (i == dict().end()) return nullptr;
|
||||
return &i->second;
|
||||
}
|
||||
|
||||
entry const* entry::find_key(std::string const& key) const
|
||||
{
|
||||
dictionary_type::const_iterator i = dict().find(key);
|
||||
if (i == dict().end()) return 0;
|
||||
if (i == dict().end()) return nullptr;
|
||||
return &i->second;
|
||||
}
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
|
|||
{
|
||||
if ((rtm->rtm_addrs & (1 << i)) == 0)
|
||||
{
|
||||
rti_info[i] = 0;
|
||||
rti_info[i] = nullptr;
|
||||
continue;
|
||||
}
|
||||
rti_info[i] = sa;
|
||||
|
@ -262,9 +262,9 @@ int _System __libsocket_sysctl(int* mib, u_int namelen, void *oldp, size_t *oldl
|
|||
}
|
||||
|
||||
sa = rti_info[RTAX_GATEWAY];
|
||||
if (sa == 0
|
||||
|| rti_info[RTAX_DST] == 0
|
||||
|| rti_info[RTAX_NETMASK] == 0
|
||||
if (sa == nullptr
|
||||
|| rti_info[RTAX_DST] == nullptr
|
||||
|| rti_info[RTAX_NETMASK] == nullptr
|
||||
|| (sa->sa_family != AF_INET
|
||||
#if TORRENT_USE_IPV6
|
||||
&& sa->sa_family != AF_INET6
|
||||
|
@ -454,7 +454,7 @@ namespace libtorrent
|
|||
|
||||
for (ifaddrs* ifa = ifaddr; ifa; ifa = ifa->ifa_next)
|
||||
{
|
||||
if (ifa->ifa_addr == 0) continue;
|
||||
if (ifa->ifa_addr == nullptr) continue;
|
||||
if ((ifa->ifa_flags & IFF_UP) == 0) continue;
|
||||
|
||||
int family = ifa->ifa_addr->sa_family;
|
||||
|
@ -847,7 +847,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_OS2
|
||||
if (__libsocket_sysctl(mib, 6, 0, &needed, 0, 0) < 0)
|
||||
#else
|
||||
if (sysctl(mib, 6, 0, &needed, 0, 0) < 0)
|
||||
if (sysctl(mib, 6, nullptr, &needed, nullptr, 0) < 0)
|
||||
#endif
|
||||
{
|
||||
ec = error_code(errno, system_category());
|
||||
|
@ -860,7 +860,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
boost::scoped_array<char> buf(new (std::nothrow) char[needed]);
|
||||
if (buf.get() == 0)
|
||||
if (buf.get() == nullptr)
|
||||
{
|
||||
ec = boost::asio::error::no_memory;
|
||||
return std::vector<ip_route>();
|
||||
|
@ -869,7 +869,7 @@ namespace libtorrent
|
|||
#ifdef TORRENT_OS2
|
||||
if (__libsocket_sysctl(mib, 6, buf.get(), &needed, 0, 0) < 0)
|
||||
#else
|
||||
if (sysctl(mib, 6, buf.get(), &needed, 0, 0) < 0)
|
||||
if (sysctl(mib, 6, buf.get(), &needed, nullptr, 0) < 0)
|
||||
#endif
|
||||
{
|
||||
ec = error_code(errno, system_category());
|
||||
|
|
|
@ -143,7 +143,7 @@ namespace libtorrent
|
|||
// the offset is used to ignore the first characters in the unreserved_chars table.
|
||||
std::string escape_string_impl(const char* str, int len, int offset)
|
||||
{
|
||||
TORRENT_ASSERT(str != 0);
|
||||
TORRENT_ASSERT(str != nullptr);
|
||||
TORRENT_ASSERT(len >= 0);
|
||||
TORRENT_ASSERT(offset >= 0);
|
||||
TORRENT_ASSERT(offset < int(sizeof(unreserved_chars))-1);
|
||||
|
@ -182,7 +182,7 @@ namespace libtorrent
|
|||
{
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
if (std::strchr(unreserved_chars, *str) == 0 || *str == 0)
|
||||
if (std::strchr(unreserved_chars, *str) == nullptr || *str == 0)
|
||||
return true;
|
||||
++str;
|
||||
}
|
||||
|
|
16
src/file.cpp
16
src/file.cpp
|
@ -751,7 +751,7 @@ namespace libtorrent
|
|||
char const* next_path_element(char const* p)
|
||||
{
|
||||
p += strlen(p) + 1;
|
||||
if (*p == 0) return 0;
|
||||
if (*p == 0) return nullptr;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -777,7 +777,7 @@ namespace libtorrent
|
|||
#endif
|
||||
char const* ext = strrchr(f.c_str(), '.');
|
||||
// if we don't have an extension, just return f
|
||||
if (ext == 0 || ext == &f[0] || (slash != nullptr && ext < slash)) return f;
|
||||
if (ext == nullptr || ext == &f[0] || (slash != nullptr && ext < slash)) return f;
|
||||
return f.substr(0, ext - &f[0]);
|
||||
}
|
||||
|
||||
|
@ -877,14 +877,14 @@ namespace libtorrent
|
|||
|
||||
char const* filename_cstr(char const* f)
|
||||
{
|
||||
if (f == 0) return f;
|
||||
if (f == nullptr) return f;
|
||||
|
||||
char const* sep = strrchr(f, '/');
|
||||
#ifdef TORRENT_WINDOWS
|
||||
char const* altsep = strrchr(f, '\\');
|
||||
if (sep == 0 || altsep > sep) sep = altsep;
|
||||
#endif
|
||||
if (sep == 0) return f;
|
||||
if (sep == nullptr) return f;
|
||||
return sep+1;
|
||||
}
|
||||
|
||||
|
@ -897,7 +897,7 @@ namespace libtorrent
|
|||
char const* altsep = strrchr(first, '\\');
|
||||
if (sep == 0 || altsep > sep) sep = altsep;
|
||||
#endif
|
||||
if (sep == 0) return f;
|
||||
if (sep == nullptr) return f;
|
||||
|
||||
if (sep - first == int(f.size()) - 1)
|
||||
{
|
||||
|
@ -984,7 +984,7 @@ namespace libtorrent
|
|||
#endif // TORRENT_USE_WSTRING
|
||||
#else
|
||||
char cwd[TORRENT_MAX_PATH];
|
||||
if (getcwd(cwd, sizeof(cwd)) == 0) return "/";
|
||||
if (getcwd(cwd, sizeof(cwd)) == nullptr) return "/";
|
||||
#endif
|
||||
#if defined TORRENT_WINDOWS && !defined TORRENT_MINGW && TORRENT_USE_WSTRING
|
||||
return convert_from_wstring(cwd);
|
||||
|
@ -1213,7 +1213,7 @@ namespace libtorrent
|
|||
|
||||
p = convert_to_native(p);
|
||||
m_handle = opendir(p.c_str());
|
||||
if (m_handle == 0)
|
||||
if (m_handle == nullptr)
|
||||
{
|
||||
ec.assign(errno, system_category());
|
||||
m_done = true;
|
||||
|
@ -1280,7 +1280,7 @@ namespace libtorrent
|
|||
ec.assign(errno, system_category());
|
||||
m_done = true;
|
||||
}
|
||||
if (dummy == 0) m_done = true;
|
||||
if (dummy == nullptr) m_done = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ namespace libtorrent
|
|||
== m_deleted_storages.end());
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT(st != 0);
|
||||
TORRENT_ASSERT(st != nullptr);
|
||||
TORRENT_ASSERT(is_complete(p));
|
||||
TORRENT_ASSERT((m & file::rw_mask) == file::read_only
|
||||
|| (m & file::rw_mask) == file::read_write);
|
||||
|
@ -281,7 +281,7 @@ namespace libtorrent
|
|||
{
|
||||
std::unique_lock<std::mutex> l(m_mutex);
|
||||
|
||||
if (st == 0)
|
||||
if (st == nullptr)
|
||||
{
|
||||
file_set tmp;
|
||||
tmp.swap(m_files);
|
||||
|
|
|
@ -245,7 +245,7 @@ namespace libtorrent
|
|||
, hidden_attribute(fe.hidden_attribute)
|
||||
, executable_attribute(fe.executable_attribute)
|
||||
, symlink_attribute(fe.symlink_attribute)
|
||||
, name(0)
|
||||
, name(nullptr)
|
||||
, path_index(fe.path_index)
|
||||
{
|
||||
if (fe.name_len == name_is_owned)
|
||||
|
@ -610,7 +610,7 @@ namespace libtorrent
|
|||
|
||||
sha1_hash file_storage::hash(int index) const
|
||||
{
|
||||
if (index >= int(m_file_hashes.size())) return sha1_hash(0);
|
||||
if (index >= int(m_file_hashes.size())) return sha1_hash(nullptr);
|
||||
return sha1_hash(m_file_hashes[index]);
|
||||
}
|
||||
|
||||
|
@ -847,7 +847,7 @@ namespace libtorrent
|
|||
sha1_hash file_storage::hash(internal_file_entry const& fe) const
|
||||
{
|
||||
int index = &fe - &m_files[0];
|
||||
if (index >= int(m_file_hashes.size())) return sha1_hash(0);
|
||||
if (index >= int(m_file_hashes.size())) return sha1_hash(nullptr);
|
||||
return sha1_hash(m_file_hashes[index]);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace libtorrent
|
|||
// returns -1 if gzip header is invalid or the header size in bytes
|
||||
int gzip_header(const char* buf, int size)
|
||||
{
|
||||
TORRENT_ASSERT(buf != 0);
|
||||
TORRENT_ASSERT(buf != nullptr);
|
||||
|
||||
const unsigned char* buffer = reinterpret_cast<const unsigned char*>(buf);
|
||||
const int total_size = size;
|
||||
|
@ -122,7 +122,7 @@ namespace libtorrent
|
|||
// gzip is defined in https://tools.ietf.org/html/rfc1952
|
||||
|
||||
// The zip header cannot be shorter than 10 bytes
|
||||
if (size < 10 || buf == 0) return -1;
|
||||
if (size < 10 || buf == nullptr) return -1;
|
||||
|
||||
// check the magic header of gzip
|
||||
if ((buffer[0] != GZIP_MAGIC0) || (buffer[1] != GZIP_MAGIC1)) return -1;
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace libtorrent
|
|||
hasher::hasher(const char* data, int len)
|
||||
: hasher()
|
||||
{
|
||||
TORRENT_ASSERT(data != 0);
|
||||
TORRENT_ASSERT(data != nullptr);
|
||||
TORRENT_ASSERT(len > 0);
|
||||
update(data, len);
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ namespace libtorrent
|
|||
|
||||
hasher& hasher::update(const char* data, int len)
|
||||
{
|
||||
TORRENT_ASSERT(data != 0);
|
||||
TORRENT_ASSERT(data != nullptr);
|
||||
TORRENT_ASSERT(len > 0);
|
||||
#ifdef TORRENT_USE_LIBGCRYPT
|
||||
gcry_md_write(m_context, data, len);
|
||||
|
|
|
@ -70,7 +70,7 @@ http_connection::http_connection(io_service& ios
|
|||
, m_own_ssl_context(false)
|
||||
#endif
|
||||
#if TORRENT_USE_I2P
|
||||
, m_i2p_conn(0)
|
||||
, m_i2p_conn(nullptr)
|
||||
#endif
|
||||
, m_resolver(resolver)
|
||||
, m_handler(handler)
|
||||
|
@ -320,11 +320,11 @@ void http_connection::start(std::string const& hostname, int port
|
|||
|| proxy->type == settings_pack::http_pw)
|
||||
&& !ssl)
|
||||
{
|
||||
proxy = 0;
|
||||
proxy = nullptr;
|
||||
}
|
||||
aux::proxy_settings null_proxy;
|
||||
|
||||
void* userdata = 0;
|
||||
void* userdata = nullptr;
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
if (m_ssl)
|
||||
{
|
||||
|
@ -643,7 +643,7 @@ void http_connection::callback(error_code e, char* data, int size)
|
|||
return;
|
||||
}
|
||||
size = int(buf.size());
|
||||
data = size == 0 ? 0 : &buf[0];
|
||||
data = size == 0 ? nullptr : &buf[0];
|
||||
}
|
||||
|
||||
// if we completed the whole response, no need
|
||||
|
@ -720,7 +720,7 @@ void http_connection::on_read(error_code const& e
|
|||
{
|
||||
error_code ec = boost::asio::error::eof;
|
||||
TORRENT_ASSERT(bytes_transferred == 0);
|
||||
char* data = 0;
|
||||
char* data = nullptr;
|
||||
std::size_t size = 0;
|
||||
if (m_bottled && m_parser.header_finished())
|
||||
{
|
||||
|
@ -751,7 +751,7 @@ void http_connection::on_read(error_code const& e
|
|||
{
|
||||
// HTTP parse error
|
||||
error_code ec = errors::http_parse_error;
|
||||
callback(ec, 0, 0);
|
||||
callback(ec, nullptr, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ namespace libtorrent
|
|||
, m_content_length(-1)
|
||||
, m_range_start(-1)
|
||||
, m_range_end(-1)
|
||||
, m_recv_buffer(0, 0)
|
||||
, m_recv_buffer(nullptr, nullptr)
|
||||
, m_cur_chunk_end(-1)
|
||||
, m_status_code(-1)
|
||||
, m_chunk_header_size(0)
|
||||
|
@ -279,7 +279,7 @@ restart_response:
|
|||
|
||||
if (name == "content-length")
|
||||
{
|
||||
m_content_length = strtoll(value.c_str(), 0, 10);
|
||||
m_content_length = strtoll(value.c_str(), nullptr, 10);
|
||||
if (m_content_length < 0)
|
||||
{
|
||||
m_state = error_state;
|
||||
|
@ -471,7 +471,7 @@ restart_response:
|
|||
// empty line
|
||||
|
||||
// first, read the chunk length
|
||||
*chunk_size = strtoll(pos, 0, 16);
|
||||
*chunk_size = strtoll(pos, nullptr, 16);
|
||||
if (*chunk_size < 0) return true;
|
||||
|
||||
if (*chunk_size != 0)
|
||||
|
@ -558,8 +558,8 @@ restart_response:
|
|||
m_range_end = -1;
|
||||
m_finished = false;
|
||||
m_state = read_status;
|
||||
m_recv_buffer.begin = 0;
|
||||
m_recv_buffer.end = 0;
|
||||
m_recv_buffer.begin = nullptr;
|
||||
m_recv_buffer.end = nullptr;
|
||||
m_header.clear();
|
||||
m_chunked_encoding = false;
|
||||
m_chunked_ranges.clear();
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace libtorrent
|
|||
{
|
||||
m_buffer.push_back(0);
|
||||
char* status = std::strchr(&m_buffer[0], ' ');
|
||||
if (status == 0)
|
||||
if (status == nullptr)
|
||||
{
|
||||
(*h)(boost::asio::error::operation_not_supported);
|
||||
error_code ec;
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace libtorrent
|
|||
void i2p_connection::set_local_endpoint(error_code const& ec, char const* dest
|
||||
, i2p_stream::handler_type const& h)
|
||||
{
|
||||
if (!ec && dest != 0)
|
||||
if (!ec && dest != nullptr)
|
||||
m_i2p_local_endpoint = dest;
|
||||
else
|
||||
m_i2p_local_endpoint.clear();
|
||||
|
@ -205,7 +205,7 @@ namespace libtorrent
|
|||
|
||||
if (ec)
|
||||
{
|
||||
handler(ec, 0);
|
||||
handler(ec, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ namespace libtorrent
|
|||
|
||||
i2p_stream::i2p_stream(io_service& io_service)
|
||||
: proxy_base(io_service)
|
||||
, m_id(0)
|
||||
, m_id(nullptr)
|
||||
, m_command(cmd_create_session)
|
||||
, m_state(0)
|
||||
{
|
||||
|
@ -314,8 +314,8 @@ namespace libtorrent
|
|||
char* ptr = &m_buffer[0];
|
||||
char* next = ptr;
|
||||
|
||||
char const* expect1 = 0;
|
||||
char const* expect2 = 0;
|
||||
char const* expect1 = nullptr;
|
||||
char const* expect2 = nullptr;
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
|
@ -340,9 +340,9 @@ namespace libtorrent
|
|||
|
||||
// std::fprintf(stderr, "<<< %s\n", &m_buffer[0]);
|
||||
ptr = string_tokenize(next, ' ', &next);
|
||||
if (ptr == 0 || expect1 == 0 || strcmp(expect1, ptr)) { handle_error(invalid_response, h); return; }
|
||||
if (ptr == nullptr || expect1 == nullptr || strcmp(expect1, ptr)) { handle_error(invalid_response, h); return; }
|
||||
ptr = string_tokenize(next, ' ', &next);
|
||||
if (ptr == 0 || expect2 == 0 || strcmp(expect2, ptr)) { handle_error(invalid_response, h); return; }
|
||||
if (ptr == nullptr || expect2 == nullptr || strcmp(expect2, ptr)) { handle_error(invalid_response, h); return; }
|
||||
|
||||
int result = 0;
|
||||
// char const* message = 0;
|
||||
|
@ -351,10 +351,10 @@ namespace libtorrent
|
|||
for(;;)
|
||||
{
|
||||
char* name = string_tokenize(next, '=', &next);
|
||||
if (name == 0) break;
|
||||
if (name == nullptr) break;
|
||||
// std::fprintf(stderr, "name=\"%s\"\n", name);
|
||||
char* ptr2 = string_tokenize(next, ' ', &next);
|
||||
if (ptr2 == 0) { handle_error(invalid_response, h); return; }
|
||||
if (ptr2 == nullptr) { handle_error(invalid_response, h); return; }
|
||||
// std::fprintf(stderr, "value=\"%s\"\n", ptr2);
|
||||
|
||||
if (strcmp("RESULT", name) == 0)
|
||||
|
|
|
@ -308,7 +308,7 @@ namespace
|
|||
#endif
|
||||
|
||||
char temp[3];
|
||||
char const* name = 0;
|
||||
char const* name = nullptr;
|
||||
if (i < name_map + size && std::equal(f.name, f.name + 2, i->id))
|
||||
{
|
||||
name = i->name;
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace libtorrent
|
|||
else if (ps.type == settings_pack::i2p_proxy)
|
||||
{
|
||||
// it doesn't make any sense to try ssl over i2p
|
||||
TORRENT_ASSERT(ssl_context == 0);
|
||||
TORRENT_ASSERT(ssl_context == nullptr);
|
||||
s.instantiate<i2p_stream>(ios);
|
||||
s.get<i2p_stream>()->set_proxy(ps.hostname, ps.port);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace
|
|||
|
||||
struct dht_immutable_item
|
||||
{
|
||||
dht_immutable_item() : value(0), num_announcers(0), size(0) {}
|
||||
dht_immutable_item() : value(nullptr), num_announcers(0), size(0) {}
|
||||
// malloced space for the actual value
|
||||
char* value;
|
||||
// this counts the number of IPs we have seen
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace libtorrent { namespace dht
|
|||
|
||||
bool dos_blocker::incoming(address addr, time_point now, dht_logger* logger)
|
||||
{
|
||||
node_ban_entry* match = 0;
|
||||
node_ban_entry* match = nullptr;
|
||||
node_ban_entry* min = m_ban_nodes;
|
||||
for (node_ban_entry* i = m_ban_nodes; i < m_ban_nodes + num_ban_nodes; ++i)
|
||||
{
|
||||
|
|
|
@ -219,7 +219,7 @@ void node::bootstrap(std::vector<udp::endpoint> const& nodes
|
|||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
++count;
|
||||
#endif
|
||||
r->add_entry(node_id(0), *i, observer::flag_initial);
|
||||
r->add_entry(node_id(nullptr), *i, observer::flag_initial);
|
||||
}
|
||||
|
||||
// make us start as far away from our node ID as possible
|
||||
|
@ -381,7 +381,7 @@ namespace
|
|||
#endif
|
||||
|
||||
void* ptr = node.m_rpc.allocate_observer();
|
||||
if (ptr == 0) return;
|
||||
if (ptr == nullptr) return;
|
||||
observer_ptr o(new (ptr) announce_observer(algo, i->first.ep(), i->first.id));
|
||||
#if TORRENT_USE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
|
@ -468,7 +468,7 @@ void node::direct_request(udp::endpoint ep, entry& e
|
|||
new direct_traversal(*this, (node_id::min)(), f));
|
||||
|
||||
void* ptr = m_rpc.allocate_observer();
|
||||
if (ptr == 0) return;
|
||||
if (ptr == nullptr) return;
|
||||
observer_ptr o(new (ptr) direct_observer(algo, ep, (node_id::min)()));
|
||||
#if TORRENT_USE_ASSERTS
|
||||
o->m_in_constructor = false;
|
||||
|
@ -672,7 +672,7 @@ void node::send_single_refresh(udp::endpoint const& ep, int bucket
|
|||
{
|
||||
TORRENT_ASSERT(id != m_id);
|
||||
void* ptr = m_rpc.allocate_observer();
|
||||
if (ptr == 0) return;
|
||||
if (ptr == nullptr) return;
|
||||
|
||||
TORRENT_ASSERT(bucket >= 0);
|
||||
TORRENT_ASSERT(bucket <= 159);
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace libtorrent { namespace dht
|
|||
|
||||
node_entry::node_entry(udp::endpoint ep)
|
||||
: last_queried(min_time())
|
||||
, id(0)
|
||||
, id(nullptr)
|
||||
, endpoint(ep)
|
||||
, rtt(0xffff)
|
||||
, timeout_count(0xff)
|
||||
|
@ -64,7 +64,7 @@ namespace libtorrent { namespace dht
|
|||
|
||||
node_entry::node_entry()
|
||||
: last_queried(min_time())
|
||||
, id(0)
|
||||
, id(nullptr)
|
||||
, rtt(0xffff)
|
||||
, timeout_count(0xff)
|
||||
{
|
||||
|
|
|
@ -84,13 +84,13 @@ int min_distance_exp(node_id const& n1, std::vector<node_id> const& ids)
|
|||
|
||||
node_id generate_id_impl(address const& ip_, std::uint32_t r)
|
||||
{
|
||||
std::uint8_t* ip = 0;
|
||||
std::uint8_t* ip = nullptr;
|
||||
|
||||
static const std::uint8_t v4mask[] = { 0x03, 0x0f, 0x3f, 0xff };
|
||||
#if TORRENT_USE_IPV6
|
||||
static const std::uint8_t v6mask[] = { 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
|
||||
#endif
|
||||
std::uint8_t const* mask = 0;
|
||||
std::uint8_t const* mask = nullptr;
|
||||
int num_octets = 0;
|
||||
|
||||
address_v4::bytes_type b4;
|
||||
|
@ -209,7 +209,7 @@ node_id generate_prefix_mask(int bits)
|
|||
{
|
||||
TORRENT_ASSERT(bits >= 0);
|
||||
TORRENT_ASSERT(bits <= 160);
|
||||
node_id mask(0);
|
||||
node_id mask(nullptr);
|
||||
int b = 0;
|
||||
for (; b < bits - 7; b += 8) mask[b/8] |= 0xff;
|
||||
if (bits < 160) mask[b/8] |= (0xff << (8 - (bits&7))) & 0xff;
|
||||
|
|
|
@ -61,7 +61,7 @@ void put_data::set_targets(std::vector<std::pair<node_entry, std::string> > cons
|
|||
, end(targets.end()); i != end; ++i)
|
||||
{
|
||||
void* ptr = m_node.m_rpc.allocate_observer();
|
||||
if (ptr == 0) return;
|
||||
if (ptr == nullptr) return;
|
||||
|
||||
observer_ptr o(new (ptr) put_data_observer(this, i->first.ep()
|
||||
, i->first.id, i->second));
|
||||
|
|
|
@ -544,7 +544,7 @@ node_entry* routing_table::find_node(udp::endpoint const& ep
|
|||
}
|
||||
}
|
||||
*bucket = m_buckets.end();
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void routing_table::remove_node(node_entry* n
|
||||
|
@ -641,7 +641,7 @@ routing_table::add_node_status_t routing_table::add_node_impl(node_entry e)
|
|||
|
||||
table_t::iterator existing_bucket;
|
||||
node_entry* existing = find_node(e.ep(), &existing_bucket);
|
||||
if (existing == 0)
|
||||
if (existing == nullptr)
|
||||
{
|
||||
// the node we're trying to add is not a match with an existing node. we
|
||||
// should ignore it, unless we allow duplicate IPs in our routing
|
||||
|
|
|
@ -71,14 +71,14 @@ namespace io = libtorrent::detail;
|
|||
|
||||
void intrusive_ptr_add_ref(observer const* o)
|
||||
{
|
||||
TORRENT_ASSERT(o != 0);
|
||||
TORRENT_ASSERT(o != nullptr);
|
||||
TORRENT_ASSERT(o->m_refs < 0xffff);
|
||||
++o->m_refs;
|
||||
}
|
||||
|
||||
void intrusive_ptr_release(observer const* o)
|
||||
{
|
||||
TORRENT_ASSERT(o != 0);
|
||||
TORRENT_ASSERT(o != nullptr);
|
||||
TORRENT_ASSERT(o->m_refs > 0);
|
||||
if (--o->m_refs == 0)
|
||||
{
|
||||
|
|
|
@ -118,7 +118,7 @@ void traversal_algorithm::add_entry(node_id const& id, udp::endpoint addr, unsig
|
|||
{
|
||||
TORRENT_ASSERT(m_node.m_rpc.allocation_size() >= sizeof(find_data_observer));
|
||||
void* ptr = m_node.m_rpc.allocate_observer();
|
||||
if (ptr == 0)
|
||||
if (ptr == nullptr)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
if (get_node().observer())
|
||||
|
@ -526,7 +526,7 @@ void traversal_algorithm::add_router_entries()
|
|||
for (routing_table::router_iterator i = m_node.m_table.router_begin()
|
||||
, end(m_node.m_table.router_end()); i != end; ++i)
|
||||
{
|
||||
add_entry(node_id(0), *i, observer::flag_initial);
|
||||
add_entry(node_id(nullptr), *i, observer::flag_initial);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ namespace libtorrent
|
|||
++start;
|
||||
if (start == end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);
|
||||
lazy_entry* ent = top->dict_append(start);
|
||||
if (ent == 0) TORRENT_FAIL_BDECODE(boost::system::errc::not_enough_memory);
|
||||
if (ent == nullptr) TORRENT_FAIL_BDECODE(boost::system::errc::not_enough_memory);
|
||||
start += len;
|
||||
if (start >= end) TORRENT_FAIL_BDECODE(bdecode_errors::unexpected_eof);
|
||||
stack.push_back(ent);
|
||||
|
@ -162,7 +162,7 @@ namespace libtorrent
|
|||
continue;
|
||||
}
|
||||
lazy_entry* ent = top->list_append();
|
||||
if (ent == 0) TORRENT_FAIL_BDECODE(boost::system::errc::not_enough_memory);
|
||||
if (ent == nullptr) TORRENT_FAIL_BDECODE(boost::system::errc::not_enough_memory);
|
||||
stack.push_back(ent);
|
||||
break;
|
||||
}
|
||||
|
@ -339,28 +339,28 @@ namespace libtorrent
|
|||
std::string lazy_entry::dict_find_string_value(char const* name) const
|
||||
{
|
||||
lazy_entry const* e = dict_find(name);
|
||||
if (e == 0 || e->type() != lazy_entry::string_t) return std::string();
|
||||
if (e == nullptr || e->type() != lazy_entry::string_t) return std::string();
|
||||
return e->string_value();
|
||||
}
|
||||
|
||||
pascal_string lazy_entry::dict_find_pstr(char const* name) const
|
||||
{
|
||||
lazy_entry const* e = dict_find(name);
|
||||
if (e == 0 || e->type() != lazy_entry::string_t) return pascal_string(0, 0);
|
||||
if (e == nullptr || e->type() != lazy_entry::string_t) return pascal_string(nullptr, 0);
|
||||
return e->string_pstr();
|
||||
}
|
||||
|
||||
lazy_entry const* lazy_entry::dict_find_string(char const* name) const
|
||||
{
|
||||
lazy_entry const* e = dict_find(name);
|
||||
if (e == 0 || e->type() != lazy_entry::string_t) return 0;
|
||||
if (e == nullptr || e->type() != lazy_entry::string_t) return nullptr;
|
||||
return e;
|
||||
}
|
||||
|
||||
lazy_entry const* lazy_entry::dict_find_int(char const* name) const
|
||||
{
|
||||
lazy_entry const* e = dict_find(name);
|
||||
if (e == 0 || e->type() != lazy_entry::int_t) return 0;
|
||||
if (e == nullptr || e->type() != lazy_entry::int_t) return nullptr;
|
||||
return e;
|
||||
}
|
||||
|
||||
|
@ -368,28 +368,28 @@ namespace libtorrent
|
|||
, std::int64_t default_val) const
|
||||
{
|
||||
lazy_entry const* e = dict_find(name);
|
||||
if (e == 0 || e->type() != lazy_entry::int_t) return default_val;
|
||||
if (e == nullptr || e->type() != lazy_entry::int_t) return default_val;
|
||||
return e->int_value();
|
||||
}
|
||||
|
||||
lazy_entry const* lazy_entry::dict_find_dict(char const* name) const
|
||||
{
|
||||
lazy_entry const* e = dict_find(name);
|
||||
if (e == 0 || e->type() != lazy_entry::dict_t) return 0;
|
||||
if (e == nullptr || e->type() != lazy_entry::dict_t) return nullptr;
|
||||
return e;
|
||||
}
|
||||
|
||||
lazy_entry const* lazy_entry::dict_find_dict(std::string const& name) const
|
||||
{
|
||||
lazy_entry const* e = dict_find(name);
|
||||
if (e == 0 || e->type() != lazy_entry::dict_t) return 0;
|
||||
if (e == nullptr || e->type() != lazy_entry::dict_t) return nullptr;
|
||||
return e;
|
||||
}
|
||||
|
||||
lazy_entry const* lazy_entry::dict_find_list(char const* name) const
|
||||
{
|
||||
lazy_entry const* e = dict_find(name);
|
||||
if (e == 0 || e->type() != lazy_entry::list_t) return 0;
|
||||
if (e == nullptr || e->type() != lazy_entry::list_t) return nullptr;
|
||||
return e;
|
||||
}
|
||||
|
||||
|
@ -402,7 +402,7 @@ namespace libtorrent
|
|||
if (string_equal(name, e.name, e.val.m_begin - e.name))
|
||||
return &e.val;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
lazy_entry* lazy_entry::dict_find(std::string const& name)
|
||||
|
@ -415,7 +415,7 @@ namespace libtorrent
|
|||
if (std::equal(name.begin(), name.end(), e.name))
|
||||
return &e.val;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
lazy_entry* lazy_entry::list_append()
|
||||
|
@ -426,7 +426,7 @@ namespace libtorrent
|
|||
{
|
||||
int capacity = lazy_entry_list_init;
|
||||
m_data.list = new (std::nothrow) lazy_entry[capacity+1];
|
||||
if (m_data.list == 0) return 0;
|
||||
if (m_data.list == nullptr) return nullptr;
|
||||
m_data.list[0].m_len = capacity;
|
||||
}
|
||||
else if (m_size == this->capacity())
|
||||
|
@ -449,21 +449,21 @@ namespace libtorrent
|
|||
std::string lazy_entry::list_string_value_at(int i) const
|
||||
{
|
||||
lazy_entry const* e = list_at(i);
|
||||
if (e == 0 || e->type() != lazy_entry::string_t) return std::string();
|
||||
if (e == nullptr || e->type() != lazy_entry::string_t) return std::string();
|
||||
return e->string_value();
|
||||
}
|
||||
|
||||
pascal_string lazy_entry::list_pstr_at(int i) const
|
||||
{
|
||||
lazy_entry const* e = list_at(i);
|
||||
if (e == 0 || e->type() != lazy_entry::string_t) return pascal_string(0, 0);
|
||||
if (e == nullptr || e->type() != lazy_entry::string_t) return pascal_string(nullptr, 0);
|
||||
return e->string_pstr();
|
||||
}
|
||||
|
||||
std::int64_t lazy_entry::list_int_value_at(int i, std::int64_t default_val) const
|
||||
{
|
||||
lazy_entry const* e = list_at(i);
|
||||
if (e == 0 || e->type() != lazy_entry::int_t) return default_val;
|
||||
if (e == nullptr || e->type() != lazy_entry::int_t) return default_val;
|
||||
return e->int_value();
|
||||
}
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buf
|
|||
continue;
|
||||
}
|
||||
|
||||
sha1_hash ih(0);
|
||||
sha1_hash ih(nullptr);
|
||||
aux::from_hex(ih_str.c_str(), 40, ih.data());
|
||||
|
||||
if (!ih.is_all_zeros() && port != 0)
|
||||
|
|
|
@ -497,7 +497,7 @@ void natpmp::on_reply(error_code const& e
|
|||
}
|
||||
#endif
|
||||
|
||||
mapping_t* m = 0;
|
||||
mapping_t* m = nullptr;
|
||||
int index = -1;
|
||||
for (std::vector<mapping_t>::iterator i = m_mappings.begin()
|
||||
, end(m_mappings.end()); i != end; ++i)
|
||||
|
@ -511,7 +511,7 @@ void natpmp::on_reply(error_code const& e
|
|||
break;
|
||||
}
|
||||
|
||||
if (m == 0)
|
||||
if (m == nullptr)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
snprintf(msg + num_chars, sizeof(msg) - num_chars, " not found in map table");
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace libtorrent {
|
|||
, std::uint32_t mask);
|
||||
|
||||
packet_buffer_impl::packet_buffer_impl()
|
||||
: m_storage(0)
|
||||
: m_storage(nullptr)
|
||||
, m_capacity(0)
|
||||
, m_size(0)
|
||||
, m_first(0)
|
||||
|
@ -74,7 +74,7 @@ namespace libtorrent {
|
|||
// you're not allowed to insert NULLs!
|
||||
TORRENT_ASSERT(value);
|
||||
|
||||
if (value == 0) return remove(idx);
|
||||
if (value == nullptr) return remove(idx);
|
||||
|
||||
if (m_size != 0)
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ namespace libtorrent {
|
|||
if (m_size == 0) m_first = idx;
|
||||
// if we're just replacing an old value, the number
|
||||
// of elements in the buffer doesn't actually increase
|
||||
if (old_value == 0) ++m_size;
|
||||
if (old_value == nullptr) ++m_size;
|
||||
|
||||
TORRENT_ASSERT_VAL(m_first <= 0xffff, m_first);
|
||||
return old_value;
|
||||
|
@ -137,11 +137,11 @@ namespace libtorrent {
|
|||
{
|
||||
INVARIANT_CHECK;
|
||||
if (idx >= m_first + m_capacity)
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
if (compare_less_wrap(idx, m_first, 0xffff))
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const int mask = int(m_capacity - 1);
|
||||
|
@ -163,7 +163,7 @@ namespace libtorrent {
|
|||
#endif
|
||||
|
||||
for (index_type i = 0; i < new_size; ++i)
|
||||
new_storage[i] = 0;
|
||||
new_storage[i] = nullptr;
|
||||
|
||||
for (index_type i = m_first; i < (m_first + m_capacity); ++i)
|
||||
new_storage[i & (new_size - 1)] = m_storage[i & (m_capacity - 1)];
|
||||
|
@ -179,14 +179,14 @@ namespace libtorrent {
|
|||
INVARIANT_CHECK;
|
||||
// TODO: use compare_less_wrap for this comparison as well
|
||||
if (idx >= m_first + m_capacity)
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
if (compare_less_wrap(idx, m_first, 0xffff))
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
const int mask = int(m_capacity - 1);
|
||||
void* old_value = m_storage[idx & mask];
|
||||
m_storage[idx & mask] = 0;
|
||||
m_storage[idx & mask] = nullptr;
|
||||
|
||||
if (old_value)
|
||||
{
|
||||
|
|
|
@ -349,7 +349,7 @@ void rc4_init(const unsigned char* in, unsigned long len, rc4 *state)
|
|||
unsigned char key[key_size], tmp, *s;
|
||||
int keylen, x, y, j;
|
||||
|
||||
TORRENT_ASSERT(state != 0);
|
||||
TORRENT_ASSERT(state != nullptr);
|
||||
TORRENT_ASSERT(len <= key_size);
|
||||
if (len > key_size) len = key_size;
|
||||
|
||||
|
@ -384,8 +384,8 @@ unsigned long rc4_encrypt(unsigned char *out, unsigned long outlen, rc4 *state)
|
|||
unsigned char x, y, *s, tmp;
|
||||
unsigned long n;
|
||||
|
||||
TORRENT_ASSERT(out != 0);
|
||||
TORRENT_ASSERT(state != 0);
|
||||
TORRENT_ASSERT(out != nullptr);
|
||||
TORRENT_ASSERT(state != nullptr);
|
||||
|
||||
n = outlen;
|
||||
x = state->x;
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace libtorrent
|
|||
m_peer_classes.push_back(boost::shared_ptr<peer_class>());
|
||||
}
|
||||
|
||||
TORRENT_ASSERT(m_peer_classes[ret].get() == 0);
|
||||
TORRENT_ASSERT(m_peer_classes[ret].get() == nullptr);
|
||||
m_peer_classes[ret] = boost::make_shared<peer_class>(label);
|
||||
return ret;
|
||||
}
|
||||
|
@ -114,13 +114,13 @@ namespace libtorrent
|
|||
|
||||
peer_class* peer_class_pool::at(peer_class_t c)
|
||||
{
|
||||
if (c >= m_peer_classes.size()) return 0;
|
||||
if (c >= m_peer_classes.size()) return nullptr;
|
||||
return m_peer_classes[c].get();
|
||||
}
|
||||
|
||||
peer_class const* peer_class_pool::at(peer_class_t c) const
|
||||
{
|
||||
if (c >= m_peer_classes.size()) return 0;
|
||||
if (c >= m_peer_classes.size()) return nullptr;
|
||||
return m_peer_classes[c].get();
|
||||
}
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ namespace libtorrent
|
|||
m_quota[0] = 0;
|
||||
m_quota[1] = 0;
|
||||
|
||||
TORRENT_ASSERT(pack.peerinfo == 0 || pack.peerinfo->banned == false);
|
||||
TORRENT_ASSERT(pack.peerinfo == nullptr || pack.peerinfo->banned == false);
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
error_code ec;
|
||||
TORRENT_ASSERT(m_socket->remote_endpoint(ec) == m_remote || ec);
|
||||
|
@ -295,7 +295,7 @@ namespace libtorrent
|
|||
void peer_connection::start()
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
TORRENT_ASSERT(m_peer_info == 0 || m_peer_info->connection == this);
|
||||
TORRENT_ASSERT(m_peer_info == nullptr || m_peer_info->connection == this);
|
||||
boost::shared_ptr<torrent> t = m_torrent.lock();
|
||||
|
||||
if (!m_outgoing)
|
||||
|
@ -537,7 +537,7 @@ namespace libtorrent
|
|||
{
|
||||
if (strcmp((*i)->type(), type) == 0) return (*i).get();
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -818,7 +818,7 @@ namespace libtorrent
|
|||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
if (m_peer_info)
|
||||
TORRENT_ASSERT(m_peer_info->connection == 0);
|
||||
TORRENT_ASSERT(m_peer_info->connection == nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1388,7 +1388,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
// clear the requests that haven't been sent yet
|
||||
if (peer_info_struct() == 0 || !peer_info_struct()->on_parole)
|
||||
if (peer_info_struct() == nullptr || !peer_info_struct()->on_parole)
|
||||
{
|
||||
// if the peer is not in parole mode, clear the queued
|
||||
// up block requests
|
||||
|
@ -5282,7 +5282,7 @@ namespace libtorrent
|
|||
return;
|
||||
}
|
||||
|
||||
TORRENT_ASSERT(j->buffer.disk_block == 0);
|
||||
TORRENT_ASSERT(j->buffer.disk_block == nullptr);
|
||||
write_dont_have(r.piece);
|
||||
write_reject_request(r);
|
||||
if (t->alerts().should_post<file_error_alert>())
|
||||
|
@ -5762,7 +5762,7 @@ namespace libtorrent
|
|||
// this should always succeed, because we checked how much space
|
||||
// there was up-front
|
||||
TORRENT_UNUSED(dst);
|
||||
TORRENT_ASSERT(dst != 0);
|
||||
TORRENT_ASSERT(dst != nullptr);
|
||||
size -= free_space;
|
||||
buf += free_space;
|
||||
}
|
||||
|
@ -5772,7 +5772,7 @@ namespace libtorrent
|
|||
while (size > 0)
|
||||
{
|
||||
char* chain_buf = m_ses.allocate_buffer();
|
||||
if (chain_buf == 0)
|
||||
if (chain_buf == nullptr)
|
||||
{
|
||||
disconnect(errors::no_memory, op_alloc_sndbuf);
|
||||
return;
|
||||
|
@ -6378,7 +6378,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(m_peer_info->prev_amount_upload == 0);
|
||||
TORRENT_ASSERT(m_peer_info->prev_amount_download == 0);
|
||||
TORRENT_ASSERT(m_peer_info->connection == this
|
||||
|| m_peer_info->connection == 0);
|
||||
|| m_peer_info->connection == nullptr);
|
||||
|
||||
if (m_peer_info->optimistically_unchoked)
|
||||
TORRENT_ASSERT(!is_choked());
|
||||
|
|
|
@ -184,8 +184,8 @@ namespace libtorrent
|
|||
i = m_peers.begin() + current;
|
||||
continue;
|
||||
}
|
||||
TORRENT_ASSERT((*i)->connection == 0
|
||||
|| (*i)->connection->peer_info_struct() == 0);
|
||||
TORRENT_ASSERT((*i)->connection == nullptr
|
||||
|| (*i)->connection->peer_info_struct() == nullptr);
|
||||
}
|
||||
|
||||
erase_peer(i, state);
|
||||
|
@ -243,8 +243,8 @@ namespace libtorrent
|
|||
i = m_peers.begin() + current;
|
||||
continue;
|
||||
}
|
||||
TORRENT_ASSERT((*i)->connection == 0
|
||||
|| (*i)->connection->peer_info_struct() == 0);
|
||||
TORRENT_ASSERT((*i)->connection == nullptr
|
||||
|| (*i)->connection->peer_info_struct() == nullptr);
|
||||
}
|
||||
|
||||
erase_peer(i, state);
|
||||
|
@ -328,7 +328,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(is_single_thread());
|
||||
TORRENT_ASSERT(pe.in_use);
|
||||
if (&pe == m_locked_peer) return false;
|
||||
return pe.connection == 0;
|
||||
return pe.connection == nullptr;
|
||||
}
|
||||
|
||||
void peer_list::erase_peers(torrent_state* state, int flags)
|
||||
|
@ -572,7 +572,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(!state->is_paused);
|
||||
|
||||
iterator iter;
|
||||
torrent_peer* i = 0;
|
||||
torrent_peer* i = nullptr;
|
||||
|
||||
bool found = false;
|
||||
if (state->allow_multiple_connections_per_ip)
|
||||
|
@ -626,7 +626,7 @@ namespace libtorrent
|
|||
return false;
|
||||
}
|
||||
|
||||
if (i->connection != 0)
|
||||
if (i->connection != nullptr)
|
||||
{
|
||||
bool self_connection =
|
||||
i->connection->remote() == c.local_endpoint()
|
||||
|
@ -637,7 +637,7 @@ namespace libtorrent
|
|||
c.disconnect(errors::self_connection, op_bittorrent, 1);
|
||||
TORRENT_ASSERT(i->connection->peer_info_struct() == i);
|
||||
i->connection->disconnect(errors::self_connection, op_bittorrent, 1);
|
||||
TORRENT_ASSERT(i->connection == 0);
|
||||
TORRENT_ASSERT(i->connection == nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -746,7 +746,7 @@ namespace libtorrent
|
|||
torrent_peer* p = state->peer_allocator->allocate_peer_entry(
|
||||
is_v6 ? torrent_peer_allocator_interface::ipv6_peer_type
|
||||
: torrent_peer_allocator_interface::ipv4_peer_type);
|
||||
if (p == 0) return false;
|
||||
if (p == nullptr) return false;
|
||||
|
||||
#if TORRENT_USE_IPV6
|
||||
if (is_v6)
|
||||
|
@ -770,7 +770,7 @@ namespace libtorrent
|
|||
|
||||
TORRENT_ASSERT(i);
|
||||
c.set_peer_info(i);
|
||||
TORRENT_ASSERT(i->connection == 0);
|
||||
TORRENT_ASSERT(i->connection == nullptr);
|
||||
c.add_stat(std::int64_t(i->prev_amount_download) << 10, std::int64_t(i->prev_amount_upload) << 10);
|
||||
|
||||
i->prev_amount_download = 0;
|
||||
|
@ -788,7 +788,7 @@ namespace libtorrent
|
|||
|
||||
bool peer_list::update_peer_port(int port, torrent_peer* p, int src, torrent_state* state)
|
||||
{
|
||||
TORRENT_ASSERT(p != 0);
|
||||
TORRENT_ASSERT(p != nullptr);
|
||||
TORRENT_ASSERT(p->connection);
|
||||
TORRENT_ASSERT(p->in_use);
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
|
@ -868,7 +868,7 @@ namespace libtorrent
|
|||
void peer_list::set_seed(torrent_peer* p, bool s)
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
if (p == 0) return;
|
||||
if (p == nullptr) return;
|
||||
TORRENT_ASSERT(p->in_use);
|
||||
if (p->seed == s) return;
|
||||
bool const was_conn_cand = is_connect_candidate(*p);
|
||||
|
@ -1017,7 +1017,7 @@ namespace libtorrent
|
|||
if (iter != m_peers.end() && strcmp((*iter)->dest(), destination) == 0)
|
||||
found = true;
|
||||
|
||||
torrent_peer* p = 0;
|
||||
torrent_peer* p = nullptr;
|
||||
|
||||
if (!found)
|
||||
{
|
||||
|
@ -1038,7 +1038,7 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
state->peer_allocator->free_peer_entry(p);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1059,18 +1059,18 @@ namespace libtorrent
|
|||
|
||||
// just ignore the obviously invalid entries
|
||||
if (remote.address() == address() || remote.port() == 0)
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
#if TORRENT_USE_IPV6
|
||||
// don't allow link-local IPv6 addresses since they
|
||||
// can't be used like normal addresses, they require an interface
|
||||
// and will just cause connect() to fail with EINVAL
|
||||
if (remote.address().is_v6() && remote.address().to_v6().is_link_local())
|
||||
return 0;
|
||||
return nullptr;
|
||||
#endif
|
||||
|
||||
iterator iter;
|
||||
torrent_peer* p = 0;
|
||||
torrent_peer* p = nullptr;
|
||||
|
||||
bool found = false;
|
||||
if (state->allow_multiple_connections_per_ip)
|
||||
|
@ -1121,7 +1121,7 @@ namespace libtorrent
|
|||
p->in_use = false;
|
||||
#endif
|
||||
state->peer_allocator->free_peer_entry(p);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
state->first_time_seen = true;
|
||||
}
|
||||
|
@ -1129,7 +1129,7 @@ namespace libtorrent
|
|||
{
|
||||
p = *iter;
|
||||
TORRENT_ASSERT(p->in_use);
|
||||
update_peer(p, src, flags, remote, 0);
|
||||
update_peer(p, src, flags, remote, nullptr);
|
||||
state->first_time_seen = false;
|
||||
}
|
||||
|
||||
|
@ -1187,7 +1187,7 @@ namespace libtorrent
|
|||
torrent_peer* p = c.peer_info_struct();
|
||||
|
||||
// if we couldn't find the connection in our list, just ignore it.
|
||||
if (p == 0) return;
|
||||
if (p == nullptr) return;
|
||||
|
||||
TORRENT_ASSERT(p->in_use);
|
||||
|
||||
|
@ -1205,7 +1205,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(p->connection == &c);
|
||||
TORRENT_ASSERT(!is_connect_candidate(*p));
|
||||
|
||||
p->connection = 0;
|
||||
p->connection = nullptr;
|
||||
p->optimistically_unchoked = false;
|
||||
|
||||
// if fast reconnect is true, we won't
|
||||
|
@ -1325,7 +1325,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(p.connection);
|
||||
TORRENT_ASSERT(!p.connection->is_choked());
|
||||
}
|
||||
TORRENT_ASSERT(p.connection->peer_info_struct() == 0
|
||||
TORRENT_ASSERT(p.connection->peer_info_struct() == nullptr
|
||||
|| p.connection->peer_info_struct() == &p);
|
||||
++nonempty_connections;
|
||||
}
|
||||
|
@ -1340,8 +1340,8 @@ namespace libtorrent
|
|||
bool peer_list::compare_peer_erase(torrent_peer const& lhs, torrent_peer const& rhs) const
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
TORRENT_ASSERT(lhs.connection == 0);
|
||||
TORRENT_ASSERT(rhs.connection == 0);
|
||||
TORRENT_ASSERT(lhs.connection == nullptr);
|
||||
TORRENT_ASSERT(rhs.connection == nullptr);
|
||||
|
||||
// primarily, prefer getting rid of peers we've already tried and failed
|
||||
if (lhs.failcount != rhs.failcount)
|
||||
|
|
|
@ -228,7 +228,7 @@ namespace libtorrent
|
|||
{
|
||||
info[i].num_peers = 0;
|
||||
info[i].state = block_info::state_none;
|
||||
info[i].peer = 0;
|
||||
info[i].peer = nullptr;
|
||||
#if TORRENT_USE_ASSERTS
|
||||
info[i].piece_index = piece;
|
||||
info[i].peers.clear();
|
||||
|
@ -483,7 +483,7 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
if (t != 0)
|
||||
if (t != nullptr)
|
||||
TORRENT_ASSERT(int(m_piece_map.size()) == t->torrent_file().num_pieces());
|
||||
|
||||
for (int j = 0; j < piece_pos::num_download_categories; ++j)
|
||||
|
@ -501,7 +501,7 @@ namespace libtorrent
|
|||
for (int k = 0; k < num_blocks; ++k)
|
||||
{
|
||||
TORRENT_ASSERT(info[k].piece_index == i->index);
|
||||
TORRENT_ASSERT(info[k].peer == 0
|
||||
TORRENT_ASSERT(info[k].peer == nullptr
|
||||
|| info[k].peer->in_use);
|
||||
|
||||
if (info[k].state == block_info::state_finished)
|
||||
|
@ -632,11 +632,11 @@ namespace libtorrent
|
|||
|
||||
if (p.index == piece_pos::we_have_index)
|
||||
{
|
||||
TORRENT_ASSERT(t == 0 || t->have_piece(index));
|
||||
TORRENT_ASSERT(t == nullptr || t->have_piece(index));
|
||||
TORRENT_ASSERT(p.downloading() == false);
|
||||
}
|
||||
|
||||
if (t != 0)
|
||||
if (t != nullptr)
|
||||
TORRENT_ASSERT(!t->have_piece(index));
|
||||
|
||||
int prio = p.priority(this);
|
||||
|
@ -1913,7 +1913,7 @@ namespace libtorrent
|
|||
, counters& pc
|
||||
) const
|
||||
{
|
||||
TORRENT_ASSERT(peer == 0 || peer->in_use);
|
||||
TORRENT_ASSERT(peer == nullptr || peer->in_use);
|
||||
std::uint32_t ret = 0;
|
||||
|
||||
// prevent the number of partial pieces to grow indefinitely
|
||||
|
@ -2397,7 +2397,7 @@ get_out:
|
|||
for (int j = 0; j < num_blocks_in_piece; ++j)
|
||||
{
|
||||
block_info const& info = binfo[j];
|
||||
TORRENT_ASSERT(info.peer == 0
|
||||
TORRENT_ASSERT(info.peer == nullptr
|
||||
|| static_cast<torrent_peer*>(info.peer)->in_use);
|
||||
TORRENT_ASSERT(info.piece_index == dp->index);
|
||||
if (info.state != block_info::state_requested
|
||||
|
@ -2537,7 +2537,7 @@ get_out:
|
|||
for (std::vector<block_info>::iterator i = m_block_info.begin()
|
||||
, end(m_block_info.end()); i != end; ++i)
|
||||
{
|
||||
TORRENT_ASSERT(i->peer == 0 || static_cast<torrent_peer*>(i->peer)->in_use);
|
||||
TORRENT_ASSERT(i->peer == nullptr || static_cast<torrent_peer*>(i->peer)->in_use);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -2547,7 +2547,7 @@ get_out:
|
|||
for (std::vector<block_info>::iterator i = m_block_info.begin()
|
||||
, end(m_block_info.end()); i != end; ++i)
|
||||
{
|
||||
if (i->peer == peer) i->peer = 0;
|
||||
if (i->peer == peer) i->peer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2570,7 +2570,7 @@ get_out:
|
|||
for (int j = 0; j < num_blocks_in_piece; ++j)
|
||||
{
|
||||
piece_picker::block_info const& info = binfo[j];
|
||||
TORRENT_ASSERT(info.peer == 0 || static_cast<torrent_peer*>(info.peer)->in_use);
|
||||
TORRENT_ASSERT(info.peer == nullptr || static_cast<torrent_peer*>(info.peer)->in_use);
|
||||
TORRENT_ASSERT(info.piece_index == p.index);
|
||||
if (info.state == piece_picker::block_info::state_none)
|
||||
{
|
||||
|
@ -2587,7 +2587,7 @@ get_out:
|
|||
{
|
||||
exclusive = false;
|
||||
if (info.state == piece_picker::block_info::state_requested
|
||||
&& info.peer != 0)
|
||||
&& info.peer != nullptr)
|
||||
{
|
||||
exclusive_active = false;
|
||||
}
|
||||
|
@ -3068,7 +3068,7 @@ get_out:
|
|||
<< block.piece_index << ", " << block.block_index << "} )" << std::endl;
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT(peer == 0 || static_cast<torrent_peer*>(peer)->in_use);
|
||||
TORRENT_ASSERT(peer == nullptr || static_cast<torrent_peer*>(peer)->in_use);
|
||||
TORRENT_ASSERT(block.block_index != piece_block::invalid.block_index);
|
||||
TORRENT_ASSERT(block.piece_index != piece_block::invalid.piece_index);
|
||||
TORRENT_ASSERT(block.piece_index < m_piece_map.size());
|
||||
|
@ -3215,7 +3215,7 @@ get_out:
|
|||
std::cerr << "[" << this << "] " << "mark_as_writing( {" << block.piece_index << ", " << block.block_index << "} )" << std::endl;
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT(peer == 0 || static_cast<torrent_peer*>(peer)->in_use);
|
||||
TORRENT_ASSERT(peer == nullptr || static_cast<torrent_peer*>(peer)->in_use);
|
||||
|
||||
TORRENT_ASSERT(block.block_index != piece_block::invalid.block_index);
|
||||
TORRENT_ASSERT(block.piece_index != piece_block::invalid.piece_index);
|
||||
|
@ -3360,7 +3360,7 @@ get_out:
|
|||
if (info.state == block_info::state_finished) return;
|
||||
if (info.state == block_info::state_writing) --i->writing;
|
||||
|
||||
info.peer = 0;
|
||||
info.peer = nullptr;
|
||||
info.state = block_info::state_none;
|
||||
if (i->passed_hash_check)
|
||||
{
|
||||
|
@ -3426,7 +3426,7 @@ get_out:
|
|||
TORRENT_ASSERT(info.num_peers == 0);
|
||||
info.peer = peer;
|
||||
TORRENT_ASSERT(info.state == block_info::state_writing
|
||||
|| peer == 0);
|
||||
|| peer == nullptr);
|
||||
if (info.state == block_info::state_writing)
|
||||
{
|
||||
--i->writing;
|
||||
|
@ -3467,7 +3467,7 @@ get_out:
|
|||
<< block.piece_index << ", " << block.block_index << "} )" << std::endl;
|
||||
#endif
|
||||
|
||||
TORRENT_ASSERT(peer == 0 || static_cast<torrent_peer*>(peer)->in_use);
|
||||
TORRENT_ASSERT(peer == nullptr || static_cast<torrent_peer*>(peer)->in_use);
|
||||
TORRENT_ASSERT(block.piece_index >= 0);
|
||||
TORRENT_ASSERT(block.block_index >= 0);
|
||||
TORRENT_ASSERT(block.piece_index < m_piece_map.size());
|
||||
|
@ -3525,7 +3525,7 @@ get_out:
|
|||
// and mark_as_finished. When a peer disconnects, its m_peer_info
|
||||
// pointer is set to nullptr. If so, preserve the previous peer
|
||||
// pointer, instead of forgetting who we downloaded this block from
|
||||
if (info.state != block_info::state_writing || peer != 0)
|
||||
if (info.state != block_info::state_writing || peer != nullptr)
|
||||
info.peer = peer;
|
||||
|
||||
++i->finished;
|
||||
|
@ -3598,7 +3598,7 @@ get_out:
|
|||
block_info const* binfo = blocks_for_piece(*i);
|
||||
for (int j = 0; j != num_blocks; ++j)
|
||||
{
|
||||
TORRENT_ASSERT(binfo[j].peer == 0
|
||||
TORRENT_ASSERT(binfo[j].peer == nullptr
|
||||
|| binfo[j].peer->in_use);
|
||||
d.push_back(binfo[j].peer);
|
||||
}
|
||||
|
@ -3607,7 +3607,7 @@ get_out:
|
|||
torrent_peer* piece_picker::get_downloader(piece_block block) const
|
||||
{
|
||||
int state = m_piece_map[block.piece_index].download_queue();
|
||||
if (state == piece_pos::piece_open) return 0;
|
||||
if (state == piece_pos::piece_open) return nullptr;
|
||||
|
||||
std::vector<downloading_piece>::const_iterator i = find_dl_piece(state
|
||||
, block.piece_index);
|
||||
|
@ -3619,7 +3619,7 @@ get_out:
|
|||
return nullptr;
|
||||
|
||||
torrent_peer* peer = binfo[block.block_index].peer;
|
||||
TORRENT_ASSERT(peer == 0 || static_cast<torrent_peer*>(peer)->in_use);
|
||||
TORRENT_ASSERT(peer == nullptr || static_cast<torrent_peer*>(peer)->in_use);
|
||||
return peer;
|
||||
}
|
||||
|
||||
|
@ -3634,7 +3634,7 @@ get_out:
|
|||
#ifdef TORRENT_PICKER_LOG
|
||||
std::cerr << "[" << this << "] " << "abort_download( {" << block.piece_index << ", " << block.block_index << "} )" << std::endl;
|
||||
#endif
|
||||
TORRENT_ASSERT(peer == 0 || peer->in_use);
|
||||
TORRENT_ASSERT(peer == nullptr || peer->in_use);
|
||||
|
||||
TORRENT_ASSERT(block.block_index != piece_block::invalid.block_index);
|
||||
TORRENT_ASSERT(block.piece_index != piece_block::invalid.piece_index);
|
||||
|
@ -3650,7 +3650,7 @@ get_out:
|
|||
|
||||
block_info* binfo = blocks_for_piece(*i);
|
||||
block_info& info = binfo[block.block_index];
|
||||
TORRENT_ASSERT(info.peer == 0 || info.peer->in_use);
|
||||
TORRENT_ASSERT(info.peer == nullptr || info.peer->in_use);
|
||||
TORRENT_ASSERT(info.piece_index == block.piece_index);
|
||||
|
||||
TORRENT_ASSERT(info.state != block_info::state_none);
|
||||
|
@ -3666,7 +3666,7 @@ get_out:
|
|||
#endif
|
||||
TORRENT_ASSERT(info.num_peers > 0);
|
||||
if (info.num_peers > 0) --info.num_peers;
|
||||
if (info.peer == peer) info.peer = 0;
|
||||
if (info.peer == peer) info.peer = nullptr;
|
||||
TORRENT_ASSERT(info.peers.size() == info.num_peers);
|
||||
|
||||
TORRENT_ASSERT(int(block.block_index) < blocks_in_piece(block.piece_index));
|
||||
|
@ -3675,7 +3675,7 @@ get_out:
|
|||
if (info.num_peers > 0) return;
|
||||
|
||||
// clear the downloader of this block
|
||||
info.peer = 0;
|
||||
info.peer = nullptr;
|
||||
|
||||
// clear this block as being downloaded
|
||||
info.state = block_info::state_none;
|
||||
|
|
|
@ -136,7 +136,7 @@ buffer::const_interval receive_buffer::get() const
|
|||
if (m_recv_buffer.empty())
|
||||
{
|
||||
TORRENT_ASSERT(m_recv_pos == 0);
|
||||
return buffer::interval(0,0);
|
||||
return buffer::interval(nullptr,nullptr);
|
||||
}
|
||||
|
||||
int rcv_pos = (std::min)(m_recv_pos, int(m_recv_buffer.size()) - m_recv_start);
|
||||
|
@ -150,7 +150,7 @@ buffer::interval receive_buffer::mutable_buffer()
|
|||
if (m_recv_buffer.empty())
|
||||
{
|
||||
TORRENT_ASSERT(m_recv_pos == 0);
|
||||
return buffer::interval(0,0);
|
||||
return buffer::interval(nullptr,nullptr);
|
||||
}
|
||||
int const rcv_pos = (std::min)(m_recv_pos, int(m_recv_buffer.size()));
|
||||
return buffer::interval(&m_recv_buffer[0] + m_recv_start
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace libtorrent
|
|||
// we don't want to request more blocks while trying to gracefully pause
|
||||
if (t.graceful_pause()) return false;
|
||||
|
||||
TORRENT_ASSERT(c.peer_info_struct() != 0 || c.type() != peer_connection::bittorrent_connection);
|
||||
TORRENT_ASSERT(c.peer_info_struct() != nullptr || c.type() != peer_connection::bittorrent_connection);
|
||||
|
||||
bool time_critical_mode = t.num_time_critical_pieces() > 0;
|
||||
|
||||
|
|
|
@ -293,7 +293,7 @@ namespace libtorrent
|
|||
initialize_default_settings(def);
|
||||
settings_pack pack;
|
||||
min_memory_usage(pack);
|
||||
apply_pack(&pack, def, 0);
|
||||
apply_pack(&pack, def, nullptr);
|
||||
session_settings ret;
|
||||
load_struct_from_settings(def, ret);
|
||||
return ret;
|
||||
|
@ -305,7 +305,7 @@ namespace libtorrent
|
|||
initialize_default_settings(def);
|
||||
settings_pack pack;
|
||||
high_performance_seed(pack);
|
||||
apply_pack(&pack, def, 0);
|
||||
apply_pack(&pack, def, nullptr);
|
||||
session_settings ret;
|
||||
load_struct_from_settings(def, ret);
|
||||
return ret;
|
||||
|
|
|
@ -419,7 +419,7 @@ namespace libtorrent
|
|||
void session_handle::get_cache_info(cache_status* ret
|
||||
, torrent_handle h, int flags) const
|
||||
{
|
||||
piece_manager* st = 0;
|
||||
piece_manager* st = nullptr;
|
||||
boost::shared_ptr<torrent> t = h.m_torrent.lock();
|
||||
if (t)
|
||||
{
|
||||
|
|
|
@ -1082,7 +1082,7 @@ namespace aux {
|
|||
TORRENT_ASSERT(is_single_thread());
|
||||
// if you hit this assert, you're deleting a non-existent peer class
|
||||
TORRENT_ASSERT(m_classes.at(cid));
|
||||
if (m_classes.at(cid) == 0) return;
|
||||
if (m_classes.at(cid) == nullptr) return;
|
||||
m_classes.decref(cid);
|
||||
}
|
||||
|
||||
|
@ -1092,7 +1092,7 @@ namespace aux {
|
|||
peer_class* pc = m_classes.at(cid);
|
||||
// if you hit this assert, you're passing in an invalid cid
|
||||
TORRENT_ASSERT(pc);
|
||||
if (pc == 0)
|
||||
if (pc == nullptr)
|
||||
{
|
||||
#if TORRENT_USE_INVARIANT_CHECKS
|
||||
// make it obvious that the return value is undefined
|
||||
|
@ -1143,7 +1143,7 @@ namespace aux {
|
|||
peer_class* pc = m_classes.at(cid);
|
||||
// if you hit this assert, you're passing in an invalid cid
|
||||
TORRENT_ASSERT(pc);
|
||||
if (pc == 0) return;
|
||||
if (pc == nullptr) return;
|
||||
|
||||
pc->set_info(&pci);
|
||||
}
|
||||
|
@ -1187,7 +1187,7 @@ namespace aux {
|
|||
// a bitmask referencing a non-existent peer class
|
||||
TORRENT_ASSERT_PRECOND(m_classes.at(i));
|
||||
|
||||
if (m_classes.at(i) == 0) continue;
|
||||
if (m_classes.at(i) == nullptr) continue;
|
||||
s->add_class(m_classes, i);
|
||||
}
|
||||
}
|
||||
|
@ -1198,7 +1198,7 @@ namespace aux {
|
|||
for (int i = 0; i < num; ++i)
|
||||
{
|
||||
peer_class const* pc = m_classes.at(set.class_at(i));
|
||||
if (pc == 0) continue;
|
||||
if (pc == nullptr) continue;
|
||||
if (pc->ignore_unchoke_slots) return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1387,7 +1387,7 @@ namespace aux {
|
|||
{
|
||||
peer_class* pc = m_classes.at(set.class_at(i));
|
||||
TORRENT_ASSERT(pc);
|
||||
if (pc == 0) continue;
|
||||
if (pc == nullptr) continue;
|
||||
bandwidth_channel* chan = &pc->channel[channel];
|
||||
// no need to include channels that don't have any bandwidth limits
|
||||
if (chan->throttle() == 0) continue;
|
||||
|
@ -1411,7 +1411,7 @@ namespace aux {
|
|||
for (int i = 0; i < num; ++i)
|
||||
{
|
||||
peer_class* p = m_classes.at(set.class_at(i));
|
||||
if (p == 0) continue;
|
||||
if (p == nullptr) continue;
|
||||
|
||||
bandwidth_channel* ch = &p->channel[peer_connection::download_channel];
|
||||
if (use_quota_overhead(ch, amount_down))
|
||||
|
@ -2430,7 +2430,7 @@ namespace aux {
|
|||
{
|
||||
TORRENT_ASSERT(!m_abort);
|
||||
shared_ptr<socket_type> c(new socket_type(m_io_service));
|
||||
tcp::socket* str = 0;
|
||||
tcp::socket* str = nullptr;
|
||||
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
if (ssl)
|
||||
|
@ -2821,7 +2821,7 @@ namespace aux {
|
|||
pack.tor = boost::weak_ptr<torrent>();
|
||||
pack.s = s;
|
||||
pack.endp = endp;
|
||||
pack.peerinfo = 0;
|
||||
pack.peerinfo = nullptr;
|
||||
|
||||
boost::shared_ptr<peer_connection> c
|
||||
= boost::make_shared<bt_peer_connection>(boost::cref(pack)
|
||||
|
@ -2915,7 +2915,7 @@ namespace aux {
|
|||
if (channel < 0 || channel > 1) return 0;
|
||||
|
||||
peer_class const* pc = m_classes.at(c);
|
||||
if (pc == 0) return 0;
|
||||
if (pc == nullptr) return 0;
|
||||
return pc->channel[channel].throttle();
|
||||
}
|
||||
|
||||
|
@ -2938,7 +2938,7 @@ namespace aux {
|
|||
if (channel < 0 || channel > 1) return;
|
||||
|
||||
peer_class* pc = m_classes.at(c);
|
||||
if (pc == 0) return;
|
||||
if (pc == nullptr) return;
|
||||
if (limit <= 0) limit = 0;
|
||||
pc->channel[channel].throttle(limit);
|
||||
}
|
||||
|
@ -4096,7 +4096,7 @@ namespace aux {
|
|||
torrent* const t = p->associated_torrent().lock().get();
|
||||
torrent_peer* const pi = p->peer_info_struct();
|
||||
|
||||
if (p->ignore_unchoke_slots() || t == 0 || pi == 0
|
||||
if (p->ignore_unchoke_slots() || t == nullptr || pi == nullptr
|
||||
|| pi->web_seed || t->is_paused())
|
||||
{
|
||||
p->reset_choke_counters();
|
||||
|
@ -4662,7 +4662,7 @@ namespace aux {
|
|||
if (!torrent_ptr) return handle;
|
||||
|
||||
// params.info_hash should have been initialized by add_torrent_impl()
|
||||
TORRENT_ASSERT(params.info_hash != sha1_hash(0));
|
||||
TORRENT_ASSERT(params.info_hash != sha1_hash(nullptr));
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
if (params.ti)
|
||||
|
@ -4700,8 +4700,8 @@ namespace aux {
|
|||
add_extensions_to_torrent(torrent_ptr, params.userdata);
|
||||
#endif
|
||||
|
||||
sha1_hash next_lsd(0);
|
||||
sha1_hash next_dht(0);
|
||||
sha1_hash next_lsd(nullptr);
|
||||
sha1_hash next_dht(nullptr);
|
||||
if (m_next_lsd_torrent != m_torrents.end())
|
||||
next_lsd = m_next_lsd_torrent->first;
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
|
@ -4853,7 +4853,7 @@ namespace aux {
|
|||
}
|
||||
#endif
|
||||
|
||||
if (params.info_hash == sha1_hash(0))
|
||||
if (params.info_hash == sha1_hash(nullptr))
|
||||
{
|
||||
ec = errors::missing_info_hash_in_uri;
|
||||
return std::make_pair(ptr_t(), false);
|
||||
|
|
|
@ -128,9 +128,9 @@ namespace libtorrent
|
|||
str_setting_entry_t str_settings[settings_pack::num_string_settings] =
|
||||
{
|
||||
SET(user_agent, "libtorrent/" LIBTORRENT_VERSION, &session_impl::update_user_agent),
|
||||
SET(announce_ip, 0, 0),
|
||||
SET(mmap_cache, 0, 0),
|
||||
SET(handshake_client_version, 0, 0),
|
||||
SET(announce_ip, nullptr, nullptr),
|
||||
SET(mmap_cache, nullptr, nullptr),
|
||||
SET(handshake_client_version, nullptr, nullptr),
|
||||
SET_NOPREV(outgoing_interfaces, "", &session_impl::update_outgoing_interfaces),
|
||||
#if !TORRENT_USE_IPV6
|
||||
SET_NOPREV(listen_interfaces, "0.0.0.0:6881", &session_impl::update_listen_interfaces),
|
||||
|
@ -146,205 +146,205 @@ namespace libtorrent
|
|||
|
||||
bool_setting_entry_t bool_settings[settings_pack::num_bool_settings] =
|
||||
{
|
||||
SET(allow_multiple_connections_per_ip, false, 0),
|
||||
SET(allow_multiple_connections_per_ip, false, nullptr),
|
||||
DEPRECATED_SET(ignore_limits_on_local_network, true, &session_impl::update_ignore_rate_limits_on_local_network),
|
||||
SET(send_redundant_have, true, 0),
|
||||
DEPRECATED_SET(lazy_bitfields, false, 0),
|
||||
SET(use_dht_as_fallback, false, 0),
|
||||
SET(upnp_ignore_nonrouters, false, 0),
|
||||
SET(use_parole_mode, true, 0),
|
||||
SET(use_read_cache, true, 0),
|
||||
DEPRECATED_SET(use_write_cache, true, 0),
|
||||
SET(dont_flush_write_cache, false, 0),
|
||||
SET(coalesce_reads, false, 0),
|
||||
SET(coalesce_writes, false, 0),
|
||||
SET(auto_manage_prefer_seeds, false, 0),
|
||||
SET(send_redundant_have, true, nullptr),
|
||||
DEPRECATED_SET(lazy_bitfields, false, nullptr),
|
||||
SET(use_dht_as_fallback, false, nullptr),
|
||||
SET(upnp_ignore_nonrouters, false, nullptr),
|
||||
SET(use_parole_mode, true, nullptr),
|
||||
SET(use_read_cache, true, nullptr),
|
||||
DEPRECATED_SET(use_write_cache, true, nullptr),
|
||||
SET(dont_flush_write_cache, false, nullptr),
|
||||
SET(coalesce_reads, false, nullptr),
|
||||
SET(coalesce_writes, false, nullptr),
|
||||
SET(auto_manage_prefer_seeds, false, nullptr),
|
||||
SET(dont_count_slow_torrents, true, &session_impl::update_count_slow),
|
||||
SET(close_redundant_connections, true, 0),
|
||||
SET(prioritize_partial_pieces, false, 0),
|
||||
SET(rate_limit_ip_overhead, true, 0),
|
||||
SET(announce_to_all_trackers, false, 0),
|
||||
SET(announce_to_all_tiers, false, 0),
|
||||
SET(prefer_udp_trackers, true, 0),
|
||||
SET(strict_super_seeding, false, 0),
|
||||
DEPRECATED_SET(lock_disk_cache, false, 0),
|
||||
SET(disable_hash_checks, false, 0),
|
||||
SET(allow_i2p_mixed, false, 0),
|
||||
SET(low_prio_disk, true, 0),
|
||||
SET(volatile_read_cache, false, 0),
|
||||
SET(guided_read_cache, false, 0),
|
||||
SET(no_atime_storage, true, 0),
|
||||
SET(incoming_starts_queued_torrents, false, 0),
|
||||
SET(report_true_downloaded, false, 0),
|
||||
SET(strict_end_game_mode, true, 0),
|
||||
SET(broadcast_lsd, true, 0),
|
||||
SET(enable_outgoing_utp, true, 0),
|
||||
SET(enable_incoming_utp, true, 0),
|
||||
SET(enable_outgoing_tcp, true, 0),
|
||||
SET(enable_incoming_tcp, true, 0),
|
||||
SET(ignore_resume_timestamps, false, 0),
|
||||
SET(no_recheck_incomplete_resume, false, 0),
|
||||
SET(close_redundant_connections, true, nullptr),
|
||||
SET(prioritize_partial_pieces, false, nullptr),
|
||||
SET(rate_limit_ip_overhead, true, nullptr),
|
||||
SET(announce_to_all_trackers, false, nullptr),
|
||||
SET(announce_to_all_tiers, false, nullptr),
|
||||
SET(prefer_udp_trackers, true, nullptr),
|
||||
SET(strict_super_seeding, false, nullptr),
|
||||
DEPRECATED_SET(lock_disk_cache, false, nullptr),
|
||||
SET(disable_hash_checks, false, nullptr),
|
||||
SET(allow_i2p_mixed, false, nullptr),
|
||||
SET(low_prio_disk, true, nullptr),
|
||||
SET(volatile_read_cache, false, nullptr),
|
||||
SET(guided_read_cache, false, nullptr),
|
||||
SET(no_atime_storage, true, nullptr),
|
||||
SET(incoming_starts_queued_torrents, false, nullptr),
|
||||
SET(report_true_downloaded, false, nullptr),
|
||||
SET(strict_end_game_mode, true, nullptr),
|
||||
SET(broadcast_lsd, true, nullptr),
|
||||
SET(enable_outgoing_utp, true, nullptr),
|
||||
SET(enable_incoming_utp, true, nullptr),
|
||||
SET(enable_outgoing_tcp, true, nullptr),
|
||||
SET(enable_incoming_tcp, true, nullptr),
|
||||
SET(ignore_resume_timestamps, false, nullptr),
|
||||
SET(no_recheck_incomplete_resume, false, nullptr),
|
||||
SET(anonymous_mode, false, &session_impl::update_anonymous_mode),
|
||||
SET(report_web_seed_downloads, true, &session_impl::update_report_web_seed_downloads),
|
||||
DEPRECATED_SET(rate_limit_utp, false, &session_impl::update_rate_limit_utp),
|
||||
SET(announce_double_nat, false, 0),
|
||||
SET(seeding_outgoing_connections, true, 0),
|
||||
SET(announce_double_nat, false, nullptr),
|
||||
SET(seeding_outgoing_connections, true, nullptr),
|
||||
SET(no_connect_privileged_ports, false, &session_impl::update_privileged_ports),
|
||||
SET(smooth_connects, true, 0),
|
||||
SET(always_send_user_agent, false, 0),
|
||||
SET(apply_ip_filter_to_trackers, true, 0),
|
||||
SET(use_disk_read_ahead, true, 0),
|
||||
SET(lock_files, false, 0),
|
||||
DEPRECATED_SET(contiguous_recv_buffer, true, 0),
|
||||
SET(ban_web_seeds, true, 0),
|
||||
SET_NOPREV(allow_partial_disk_writes, true, 0),
|
||||
SET(smooth_connects, true, nullptr),
|
||||
SET(always_send_user_agent, false, nullptr),
|
||||
SET(apply_ip_filter_to_trackers, true, nullptr),
|
||||
SET(use_disk_read_ahead, true, nullptr),
|
||||
SET(lock_files, false, nullptr),
|
||||
DEPRECATED_SET(contiguous_recv_buffer, true, nullptr),
|
||||
SET(ban_web_seeds, true, nullptr),
|
||||
SET_NOPREV(allow_partial_disk_writes, true, nullptr),
|
||||
SET(force_proxy, false, &session_impl::update_force_proxy),
|
||||
SET(support_share_mode, true, 0),
|
||||
SET(support_merkle_torrents, true, 0),
|
||||
SET(report_redundant_bytes, true, 0),
|
||||
SET_NOPREV(listen_system_port_fallback, true, 0),
|
||||
SET(use_disk_cache_pool, true, 0),
|
||||
SET_NOPREV(announce_crypto_support, true, 0),
|
||||
SET(support_share_mode, true, nullptr),
|
||||
SET(support_merkle_torrents, true, nullptr),
|
||||
SET(report_redundant_bytes, true, nullptr),
|
||||
SET_NOPREV(listen_system_port_fallback, true, nullptr),
|
||||
SET(use_disk_cache_pool, true, nullptr),
|
||||
SET_NOPREV(announce_crypto_support, true, nullptr),
|
||||
SET_NOPREV(enable_upnp, true, &session_impl::update_upnp),
|
||||
SET_NOPREV(enable_natpmp, true, &session_impl::update_natpmp),
|
||||
SET_NOPREV(enable_lsd, true, &session_impl::update_lsd),
|
||||
SET_NOPREV(enable_dht, true, &session_impl::update_dht),
|
||||
SET_NOPREV(prefer_rc4, false, 0),
|
||||
SET_NOPREV(proxy_hostnames, true, 0),
|
||||
SET_NOPREV(proxy_peer_connections, true, 0),
|
||||
SET_NOPREV(prefer_rc4, false, nullptr),
|
||||
SET_NOPREV(proxy_hostnames, true, nullptr),
|
||||
SET_NOPREV(proxy_peer_connections, true, nullptr),
|
||||
SET_NOPREV(auto_sequential, true, &session_impl::update_auto_sequential),
|
||||
SET_NOPREV(proxy_tracker_connections, true, 0),
|
||||
SET_NOPREV(proxy_tracker_connections, true, nullptr),
|
||||
};
|
||||
|
||||
int_setting_entry_t int_settings[settings_pack::num_int_settings] =
|
||||
{
|
||||
SET(tracker_completion_timeout, 30, 0),
|
||||
SET(tracker_receive_timeout, 10, 0),
|
||||
SET(stop_tracker_timeout, 5, 0),
|
||||
SET(tracker_maximum_response_length, 1024*1024, 0),
|
||||
SET(piece_timeout, 20, 0),
|
||||
SET(request_timeout, 60, 0),
|
||||
SET(request_queue_time, 3, 0),
|
||||
SET(max_allowed_in_request_queue, 500, 0),
|
||||
SET(max_out_request_queue, 500, 0),
|
||||
SET(whole_pieces_threshold, 20, 0),
|
||||
SET(peer_timeout, 120, 0),
|
||||
SET(urlseed_timeout, 20, 0),
|
||||
SET(urlseed_pipeline_size, 5, 0),
|
||||
SET(urlseed_wait_retry, 30, 0),
|
||||
SET(file_pool_size, 40, 0),
|
||||
SET(tracker_completion_timeout, 30, nullptr),
|
||||
SET(tracker_receive_timeout, 10, nullptr),
|
||||
SET(stop_tracker_timeout, 5, nullptr),
|
||||
SET(tracker_maximum_response_length, 1024*1024, nullptr),
|
||||
SET(piece_timeout, 20, nullptr),
|
||||
SET(request_timeout, 60, nullptr),
|
||||
SET(request_queue_time, 3, nullptr),
|
||||
SET(max_allowed_in_request_queue, 500, nullptr),
|
||||
SET(max_out_request_queue, 500, nullptr),
|
||||
SET(whole_pieces_threshold, 20, nullptr),
|
||||
SET(peer_timeout, 120, nullptr),
|
||||
SET(urlseed_timeout, 20, nullptr),
|
||||
SET(urlseed_pipeline_size, 5, nullptr),
|
||||
SET(urlseed_wait_retry, 30, nullptr),
|
||||
SET(file_pool_size, 40, nullptr),
|
||||
SET(max_failcount, 3, &session_impl::update_max_failcount),
|
||||
SET(min_reconnect_time, 60, 0),
|
||||
SET(peer_connect_timeout, 15, 0),
|
||||
SET(min_reconnect_time, 60, nullptr),
|
||||
SET(peer_connect_timeout, 15, nullptr),
|
||||
SET(connection_speed, 10, &session_impl::update_connection_speed),
|
||||
SET(inactivity_timeout, 600, 0),
|
||||
SET(unchoke_interval, 15, 0),
|
||||
SET(optimistic_unchoke_interval, 30, 0),
|
||||
SET(num_want, 200, 0),
|
||||
SET(initial_picker_threshold, 4, 0),
|
||||
SET(allowed_fast_set_size, 5, 0),
|
||||
SET(suggest_mode, settings_pack::no_piece_suggestions, 0),
|
||||
SET(inactivity_timeout, 600, nullptr),
|
||||
SET(unchoke_interval, 15, nullptr),
|
||||
SET(optimistic_unchoke_interval, 30, nullptr),
|
||||
SET(num_want, 200, nullptr),
|
||||
SET(initial_picker_threshold, 4, nullptr),
|
||||
SET(allowed_fast_set_size, 5, nullptr),
|
||||
SET(suggest_mode, settings_pack::no_piece_suggestions, nullptr),
|
||||
SET(max_queued_disk_bytes, 1024 * 1024, &session_impl::update_queued_disk_bytes),
|
||||
SET(handshake_timeout, 10, 0),
|
||||
SET(send_buffer_low_watermark, 10 * 1024, 0),
|
||||
SET(send_buffer_watermark, 500 * 1024, 0),
|
||||
SET(send_buffer_watermark_factor, 50, 0),
|
||||
SET(choking_algorithm, settings_pack::fixed_slots_choker, 0),
|
||||
SET(seed_choking_algorithm, settings_pack::round_robin, 0),
|
||||
SET(cache_size, 1024, 0),
|
||||
SET(handshake_timeout, 10, nullptr),
|
||||
SET(send_buffer_low_watermark, 10 * 1024, nullptr),
|
||||
SET(send_buffer_watermark, 500 * 1024, nullptr),
|
||||
SET(send_buffer_watermark_factor, 50, nullptr),
|
||||
SET(choking_algorithm, settings_pack::fixed_slots_choker, nullptr),
|
||||
SET(seed_choking_algorithm, settings_pack::round_robin, nullptr),
|
||||
SET(cache_size, 1024, nullptr),
|
||||
SET(cache_buffer_chunk_size, 0, &session_impl::update_cache_buffer_chunk_size),
|
||||
SET(cache_expiry, 300, 0),
|
||||
SET(disk_io_write_mode, settings_pack::enable_os_cache, 0),
|
||||
SET(disk_io_read_mode, settings_pack::enable_os_cache, 0),
|
||||
SET(outgoing_port, 0, 0),
|
||||
SET(num_outgoing_ports, 0, 0),
|
||||
SET(cache_expiry, 300, nullptr),
|
||||
SET(disk_io_write_mode, settings_pack::enable_os_cache, nullptr),
|
||||
SET(disk_io_read_mode, settings_pack::enable_os_cache, nullptr),
|
||||
SET(outgoing_port, 0, nullptr),
|
||||
SET(num_outgoing_ports, 0, nullptr),
|
||||
SET(peer_tos, 0, &session_impl::update_peer_tos),
|
||||
SET(active_downloads, 3, &session_impl::trigger_auto_manage),
|
||||
SET(active_seeds, 5, &session_impl::trigger_auto_manage),
|
||||
SET_NOPREV(active_checking, 1, &session_impl::trigger_auto_manage),
|
||||
SET(active_dht_limit, 88, 0),
|
||||
SET(active_tracker_limit, 1600, 0),
|
||||
SET(active_lsd_limit, 60, 0),
|
||||
SET(active_dht_limit, 88, nullptr),
|
||||
SET(active_tracker_limit, 1600, nullptr),
|
||||
SET(active_lsd_limit, 60, nullptr),
|
||||
SET(active_limit, 15, &session_impl::trigger_auto_manage),
|
||||
SET_NOPREV(active_loaded_limit, 100, &session_impl::trigger_auto_manage),
|
||||
SET(auto_manage_interval, 30, 0),
|
||||
SET(seed_time_limit, 24 * 60 * 60, 0),
|
||||
SET(auto_scrape_interval, 1800, 0),
|
||||
SET(auto_scrape_min_interval, 300, 0),
|
||||
SET(max_peerlist_size, 3000, 0),
|
||||
SET(max_paused_peerlist_size, 1000, 0),
|
||||
SET(min_announce_interval, 5 * 60, 0),
|
||||
SET(auto_manage_startup, 60, 0),
|
||||
SET(seeding_piece_quota, 20, 0),
|
||||
SET(max_rejects, 50, 0),
|
||||
SET(auto_manage_interval, 30, nullptr),
|
||||
SET(seed_time_limit, 24 * 60 * 60, nullptr),
|
||||
SET(auto_scrape_interval, 1800, nullptr),
|
||||
SET(auto_scrape_min_interval, 300, nullptr),
|
||||
SET(max_peerlist_size, 3000, nullptr),
|
||||
SET(max_paused_peerlist_size, 1000, nullptr),
|
||||
SET(min_announce_interval, 5 * 60, nullptr),
|
||||
SET(auto_manage_startup, 60, nullptr),
|
||||
SET(seeding_piece_quota, 20, nullptr),
|
||||
SET(max_rejects, 50, nullptr),
|
||||
SET(recv_socket_buffer_size, 0, &session_impl::update_socket_buffer_size),
|
||||
SET(send_socket_buffer_size, 0, &session_impl::update_socket_buffer_size),
|
||||
SET_NOPREV(max_peer_recv_buffer_size, 2 * 1024 * 1024, 0),
|
||||
SET(file_checks_delay_per_block, 0, 0),
|
||||
SET(read_cache_line_size, 32, 0),
|
||||
SET(write_cache_line_size, 16, 0),
|
||||
SET(optimistic_disk_retry, 10 * 60, 0),
|
||||
SET(max_suggest_pieces, 16, 0),
|
||||
SET(local_service_announce_interval, 5 * 60, 0),
|
||||
SET_NOPREV(max_peer_recv_buffer_size, 2 * 1024 * 1024, nullptr),
|
||||
SET(file_checks_delay_per_block, 0, nullptr),
|
||||
SET(read_cache_line_size, 32, nullptr),
|
||||
SET(write_cache_line_size, 16, nullptr),
|
||||
SET(optimistic_disk_retry, 10 * 60, nullptr),
|
||||
SET(max_suggest_pieces, 16, nullptr),
|
||||
SET(local_service_announce_interval, 5 * 60, nullptr),
|
||||
SET(dht_announce_interval, 15 * 60, &session_impl::update_dht_announce_interval),
|
||||
SET(udp_tracker_token_expiry, 60, 0),
|
||||
SET(default_cache_min_age, 1, 0),
|
||||
SET(num_optimistic_unchoke_slots, 0, 0),
|
||||
SET(default_est_reciprocation_rate, 16000, 0),
|
||||
SET(increase_est_reciprocation_rate, 20, 0),
|
||||
SET(decrease_est_reciprocation_rate, 3, 0),
|
||||
SET(max_pex_peers, 50, 0),
|
||||
SET(tick_interval, 500, 0),
|
||||
SET(share_mode_target, 3, 0),
|
||||
SET(udp_tracker_token_expiry, 60, nullptr),
|
||||
SET(default_cache_min_age, 1, nullptr),
|
||||
SET(num_optimistic_unchoke_slots, 0, nullptr),
|
||||
SET(default_est_reciprocation_rate, 16000, nullptr),
|
||||
SET(increase_est_reciprocation_rate, 20, nullptr),
|
||||
SET(decrease_est_reciprocation_rate, 3, nullptr),
|
||||
SET(max_pex_peers, 50, nullptr),
|
||||
SET(tick_interval, 500, nullptr),
|
||||
SET(share_mode_target, 3, nullptr),
|
||||
SET(upload_rate_limit, 0, &session_impl::update_upload_rate),
|
||||
SET(download_rate_limit, 0, &session_impl::update_download_rate),
|
||||
DEPRECATED_SET(local_upload_rate_limit, 0, &session_impl::update_local_upload_rate),
|
||||
DEPRECATED_SET(local_download_rate_limit, 0, &session_impl::update_local_download_rate),
|
||||
DEPRECATED_SET(dht_upload_rate_limit, 4000, &session_impl::update_dht_upload_rate_limit),
|
||||
SET(unchoke_slots_limit, 8, &session_impl::update_unchoke_limit),
|
||||
DEPRECATED_SET(half_open_limit, 0, 0),
|
||||
DEPRECATED_SET(half_open_limit, 0, nullptr),
|
||||
SET(connections_limit, 200, &session_impl::update_connections_limit),
|
||||
SET(connections_slack, 10, 0),
|
||||
SET(utp_target_delay, 100, 0),
|
||||
SET(utp_gain_factor, 3000, 0),
|
||||
SET(utp_min_timeout, 500, 0),
|
||||
SET(utp_syn_resends, 2, 0),
|
||||
SET(utp_fin_resends, 2, 0),
|
||||
SET(utp_num_resends, 3, 0),
|
||||
SET(utp_connect_timeout, 3000, 0),
|
||||
SET(utp_delayed_ack, 0, 0),
|
||||
SET(utp_loss_multiplier, 50, 0),
|
||||
SET(mixed_mode_algorithm, settings_pack::peer_proportional, 0),
|
||||
SET(listen_queue_size, 5, 0),
|
||||
SET(torrent_connect_boost, 10, 0),
|
||||
SET(connections_slack, 10, nullptr),
|
||||
SET(utp_target_delay, 100, nullptr),
|
||||
SET(utp_gain_factor, 3000, nullptr),
|
||||
SET(utp_min_timeout, 500, nullptr),
|
||||
SET(utp_syn_resends, 2, nullptr),
|
||||
SET(utp_fin_resends, 2, nullptr),
|
||||
SET(utp_num_resends, 3, nullptr),
|
||||
SET(utp_connect_timeout, 3000, nullptr),
|
||||
SET(utp_delayed_ack, 0, nullptr),
|
||||
SET(utp_loss_multiplier, 50, nullptr),
|
||||
SET(mixed_mode_algorithm, settings_pack::peer_proportional, nullptr),
|
||||
SET(listen_queue_size, 5, nullptr),
|
||||
SET(torrent_connect_boost, 10, nullptr),
|
||||
SET(alert_queue_size, 1000, &session_impl::update_alert_queue_size),
|
||||
SET(max_metadata_size, 3 * 1024 * 10240, 0),
|
||||
DEPRECATED_SET(hashing_threads, 1, 0),
|
||||
SET(checking_mem_usage, 256, 0),
|
||||
SET(predictive_piece_announce, 0, 0),
|
||||
SET(max_metadata_size, 3 * 1024 * 10240, nullptr),
|
||||
DEPRECATED_SET(hashing_threads, 1, nullptr),
|
||||
SET(checking_mem_usage, 256, nullptr),
|
||||
SET(predictive_piece_announce, 0, nullptr),
|
||||
SET(aio_threads, 4, &session_impl::update_disk_threads),
|
||||
SET(aio_max, 300, 0),
|
||||
SET(network_threads, 0, 0),
|
||||
SET(aio_max, 300, nullptr),
|
||||
SET(network_threads, 0, nullptr),
|
||||
DEPRECATED_SET(ssl_listen, 0, &session_impl::update_ssl_listen),
|
||||
SET(tracker_backoff, 250, 0),
|
||||
SET_NOPREV(share_ratio_limit, 200, 0),
|
||||
SET_NOPREV(seed_time_ratio_limit, 700, 0),
|
||||
SET_NOPREV(peer_turnover, 4, 0),
|
||||
SET_NOPREV(peer_turnover_cutoff, 90, 0),
|
||||
SET(peer_turnover_interval, 300, 0),
|
||||
SET_NOPREV(connect_seed_every_n_download, 10, 0),
|
||||
SET(max_http_recv_buffer_size, 4*1024*204, 0),
|
||||
SET_NOPREV(max_retry_port_bind, 10, 0),
|
||||
SET(tracker_backoff, 250, nullptr),
|
||||
SET_NOPREV(share_ratio_limit, 200, nullptr),
|
||||
SET_NOPREV(seed_time_ratio_limit, 700, nullptr),
|
||||
SET_NOPREV(peer_turnover, 4, nullptr),
|
||||
SET_NOPREV(peer_turnover_cutoff, 90, nullptr),
|
||||
SET(peer_turnover_interval, 300, nullptr),
|
||||
SET_NOPREV(connect_seed_every_n_download, 10, nullptr),
|
||||
SET(max_http_recv_buffer_size, 4*1024*204, nullptr),
|
||||
SET_NOPREV(max_retry_port_bind, 10, nullptr),
|
||||
SET_NOPREV(alert_mask, alert::error_notification, &session_impl::update_alert_mask),
|
||||
SET_NOPREV(out_enc_policy, settings_pack::pe_enabled, 0),
|
||||
SET_NOPREV(in_enc_policy, settings_pack::pe_enabled, 0),
|
||||
SET_NOPREV(allowed_enc_level, settings_pack::pe_both, 0),
|
||||
SET(inactive_down_rate, 2048, 0),
|
||||
SET(inactive_up_rate, 2048, 0),
|
||||
SET_NOPREV(out_enc_policy, settings_pack::pe_enabled, nullptr),
|
||||
SET_NOPREV(in_enc_policy, settings_pack::pe_enabled, nullptr),
|
||||
SET_NOPREV(allowed_enc_level, settings_pack::pe_both, nullptr),
|
||||
SET(inactive_down_rate, 2048, nullptr),
|
||||
SET(inactive_up_rate, 2048, nullptr),
|
||||
SET_NOPREV(proxy_type, settings_pack::none, &session_impl::update_proxy),
|
||||
SET_NOPREV(proxy_port, 0, &session_impl::update_proxy),
|
||||
SET_NOPREV(i2p_port, 0, &session_impl::update_i2p_bridge),
|
||||
SET_NOPREV(cache_size_volatile, 256, 0)
|
||||
SET_NOPREV(cache_size_volatile, 256, nullptr)
|
||||
};
|
||||
|
||||
#undef SET
|
||||
|
@ -442,7 +442,7 @@ namespace libtorrent
|
|||
// loop over all settings that differ from default
|
||||
for (int i = 0; i < settings_pack::num_string_settings; ++i)
|
||||
{
|
||||
char const* cmp = str_settings[i].default_value == 0 ? "" : str_settings[i].default_value;
|
||||
char const* cmp = str_settings[i].default_value == nullptr ? "" : str_settings[i].default_value;
|
||||
if (cmp == s.m_strings[i]) continue;
|
||||
sett[str_settings[i].name] = s.m_strings[i];
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ namespace libtorrent
|
|||
{
|
||||
for (int i = 0; i < settings_pack::num_string_settings; ++i)
|
||||
{
|
||||
if (str_settings[i].default_value == 0) continue;
|
||||
if (str_settings[i].default_value == nullptr) continue;
|
||||
s.set_str(settings_pack::string_type_base + i, str_settings[i].default_value);
|
||||
TORRENT_ASSERT(s.get_str(settings_pack::string_type_base + i) == str_settings[i].default_value);
|
||||
}
|
||||
|
|
|
@ -1126,7 +1126,7 @@ namespace libtorrent
|
|||
, const int piece, const int offset, const int num_bufs, fileop& op
|
||||
, storage_error& ec)
|
||||
{
|
||||
TORRENT_ASSERT(bufs != 0);
|
||||
TORRENT_ASSERT(bufs != nullptr);
|
||||
TORRENT_ASSERT(piece >= 0);
|
||||
TORRENT_ASSERT(piece < files.num_pieces());
|
||||
TORRENT_ASSERT(offset >= 0);
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace libtorrent
|
|||
bool is_space(char c)
|
||||
{
|
||||
static const char* ws = " \t\n\r\f\v";
|
||||
return strchr(ws, c) != 0;
|
||||
return strchr(ws, c) != nullptr;
|
||||
}
|
||||
|
||||
char to_lower(char c)
|
||||
|
@ -148,9 +148,9 @@ namespace libtorrent
|
|||
|
||||
char* allocate_string_copy(char const* str)
|
||||
{
|
||||
if (str == 0) return 0;
|
||||
if (str == nullptr) return nullptr;
|
||||
char* tmp = static_cast<char*>(std::malloc(std::strlen(str) + 1));
|
||||
if (tmp == 0) return 0;
|
||||
if (tmp == nullptr) return nullptr;
|
||||
std::strcpy(tmp, str);
|
||||
return tmp;
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ namespace libtorrent
|
|||
|
||||
char* string_tokenize(char* last, char sep, char** next)
|
||||
{
|
||||
if (last == 0) return 0;
|
||||
if (last == nullptr) return nullptr;
|
||||
if (last[0] == '"')
|
||||
{
|
||||
*next = strchr(last + 1, '"');
|
||||
|
@ -337,7 +337,7 @@ namespace libtorrent
|
|||
{
|
||||
*next = strchr(last, sep);
|
||||
}
|
||||
if (*next == 0) return last;
|
||||
if (*next == nullptr) return last;
|
||||
**next = 0;
|
||||
++(*next);
|
||||
while (**next == sep && **next) ++(*next);
|
||||
|
|
|
@ -207,7 +207,7 @@ namespace libtorrent
|
|||
#endif
|
||||
, m_stats_counters(ses.stats_counters())
|
||||
, m_storage_constructor(p.storage)
|
||||
, m_added_time(time(0))
|
||||
, m_added_time(time(nullptr))
|
||||
, m_completed_time(0)
|
||||
, m_last_seen_complete(0)
|
||||
, m_swarm_last_seen_complete(0)
|
||||
|
@ -436,7 +436,7 @@ namespace libtorrent
|
|||
m_finished_time = p.finished_time;
|
||||
m_seeding_time = p.seeding_time;
|
||||
|
||||
m_added_time = p.added_time ? p.added_time : time(0);
|
||||
m_added_time = p.added_time ? p.added_time : time(nullptr);
|
||||
m_completed_time = p.completed_time;
|
||||
if (m_completed_time != 0 && m_completed_time < m_added_time)
|
||||
m_completed_time = m_added_time;
|
||||
|
@ -1245,7 +1245,7 @@ namespace libtorrent
|
|||
|
||||
storage_interface* torrent::get_storage()
|
||||
{
|
||||
if (!m_storage) return 0;
|
||||
if (!m_storage) return nullptr;
|
||||
return m_storage->get_storage_impl();
|
||||
}
|
||||
|
||||
|
@ -1309,7 +1309,7 @@ namespace libtorrent
|
|||
peer_request p;
|
||||
p.piece = piece;
|
||||
p.start = 0;
|
||||
picker().inc_refcount(piece, 0);
|
||||
picker().inc_refcount(piece, nullptr);
|
||||
for (int i = 0; i < blocks_in_piece; ++i, p.start += block_size())
|
||||
{
|
||||
if (picker().is_finished(piece_block(piece, i))
|
||||
|
@ -1321,7 +1321,7 @@ namespace libtorrent
|
|||
// out of memory
|
||||
if (!buffer)
|
||||
{
|
||||
picker().dec_refcount(piece, 0);
|
||||
picker().dec_refcount(piece, nullptr);
|
||||
return;
|
||||
}
|
||||
std::memcpy(buffer.get(), data + p.start, p.length);
|
||||
|
@ -1329,7 +1329,7 @@ namespace libtorrent
|
|||
if (!need_loaded())
|
||||
{
|
||||
// failed to load .torrent file
|
||||
picker().dec_refcount(piece, 0);
|
||||
picker().dec_refcount(piece, nullptr);
|
||||
return;
|
||||
}
|
||||
inc_refcount("add_piece");
|
||||
|
@ -1337,11 +1337,11 @@ namespace libtorrent
|
|||
, std::bind(&torrent::on_disk_write_complete
|
||||
, shared_from_this(), _1, p));
|
||||
piece_block block(piece, i);
|
||||
picker().mark_as_downloading(block, 0);
|
||||
picker().mark_as_writing(block, 0);
|
||||
picker().mark_as_downloading(block, nullptr);
|
||||
picker().mark_as_writing(block, nullptr);
|
||||
}
|
||||
verify_piece(piece);
|
||||
picker().dec_refcount(piece, 0);
|
||||
picker().dec_refcount(piece, nullptr);
|
||||
}
|
||||
|
||||
void torrent::schedule_storage_tick()
|
||||
|
@ -1388,7 +1388,7 @@ namespace libtorrent
|
|||
// add_piece() multiple times
|
||||
if (picker().is_finished(block_finished)) return;
|
||||
|
||||
picker().mark_as_finished(block_finished, 0);
|
||||
picker().mark_as_finished(block_finished, nullptr);
|
||||
maybe_done_flushing();
|
||||
}
|
||||
|
||||
|
@ -1690,7 +1690,7 @@ namespace libtorrent
|
|||
else
|
||||
{
|
||||
params.files = &m_torrent_file->files();
|
||||
params.mapped_files = 0;
|
||||
params.mapped_files = nullptr;
|
||||
}
|
||||
params.path = m_save_path;
|
||||
params.pool = &m_ses.disk_thread().files();
|
||||
|
@ -1869,7 +1869,7 @@ namespace libtorrent
|
|||
for (; pr.length >= block; pr.length -= block, ++pb.block_index)
|
||||
{
|
||||
if (int(pb.block_index) == blocks_per_piece) { pb.block_index = 0; ++pb.piece_index; }
|
||||
m_picker->mark_as_finished(pb, 0);
|
||||
m_picker->mark_as_finished(pb, nullptr);
|
||||
}
|
||||
// ugly edge case where padfiles are not used they way they're
|
||||
// supposed to be. i.e. added back-to back or at the end
|
||||
|
@ -1877,7 +1877,7 @@ namespace libtorrent
|
|||
if (pr.length > 0 && ((i+1 != fs.num_files() && fs.pad_file_at(i+1))
|
||||
|| i + 1 == fs.num_files()))
|
||||
{
|
||||
m_picker->mark_as_finished(pb, 0);
|
||||
m_picker->mark_as_finished(pb, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2169,7 +2169,7 @@ namespace libtorrent
|
|||
{
|
||||
if (p->pid() == pid) return p;
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void torrent::on_resume_data_checked(disk_io_job const* j)
|
||||
|
@ -2341,7 +2341,7 @@ namespace libtorrent
|
|||
{
|
||||
if (blocks.get_bit(k))
|
||||
{
|
||||
m_picker->mark_as_finished(piece_block(piece, k), 0);
|
||||
m_picker->mark_as_finished(piece_block(piece, k), nullptr);
|
||||
}
|
||||
}
|
||||
if (m_picker->is_piece_finished(piece))
|
||||
|
@ -4186,14 +4186,14 @@ namespace libtorrent
|
|||
// significant operations, but we should use them right away
|
||||
// ignore nullptrs
|
||||
std::remove_copy(downloaders.begin(), downloaders.end()
|
||||
, std::inserter(peers, peers.begin()), static_cast<torrent_peer*>(0));
|
||||
, std::inserter(peers, peers.begin()), static_cast<torrent_peer*>(nullptr));
|
||||
|
||||
for (std::set<torrent_peer*>::iterator i = peers.begin()
|
||||
, end(peers.end()); i != end; ++i)
|
||||
{
|
||||
torrent_peer* p = static_cast<torrent_peer*>(*i);
|
||||
TORRENT_ASSERT(p != 0);
|
||||
if (p == 0) continue;
|
||||
TORRENT_ASSERT(p != nullptr);
|
||||
if (p == nullptr) continue;
|
||||
TORRENT_ASSERT(p->in_use);
|
||||
p->on_parole = false;
|
||||
int trust_points = p->trust_points;
|
||||
|
@ -4323,7 +4323,7 @@ namespace libtorrent
|
|||
, end(peers.end()); i != end; ++i)
|
||||
{
|
||||
torrent_peer* p = static_cast<torrent_peer*>(*i);
|
||||
if (p == 0) continue;
|
||||
if (p == nullptr) continue;
|
||||
TORRENT_ASSERT(p->in_use);
|
||||
bool allow_disconnect = true;
|
||||
if (p->connection)
|
||||
|
@ -4363,7 +4363,7 @@ namespace libtorrent
|
|||
// ban it.
|
||||
if (m_ses.alerts().should_post<peer_ban_alert>())
|
||||
{
|
||||
peer_id pid(0);
|
||||
peer_id pid(nullptr);
|
||||
if (p->connection) pid = p->connection->pid();
|
||||
m_ses.alerts().emplace_alert<peer_ban_alert>(
|
||||
get_handle(), p->ip(), pid);
|
||||
|
@ -4889,7 +4889,7 @@ namespace libtorrent
|
|||
, end(downloaders.end()); i != end; ++i, ++block)
|
||||
{
|
||||
torrent_peer* tp = *i;
|
||||
if (tp == 0 || tp->connection == 0) continue;
|
||||
if (tp == nullptr || tp->connection == nullptr) continue;
|
||||
peer_connection* peer = static_cast<peer_connection*>(tp->connection);
|
||||
peer->make_time_critical(piece_block(piece, block));
|
||||
}
|
||||
|
@ -5721,7 +5721,7 @@ namespace libtorrent
|
|||
|
||||
void torrent::remove_peer(peer_connection* p)
|
||||
{
|
||||
TORRENT_ASSERT(p != 0);
|
||||
TORRENT_ASSERT(p != nullptr);
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
|
||||
peer_iterator i = sorted_find(m_connections, p);
|
||||
|
@ -5787,7 +5787,7 @@ namespace libtorrent
|
|||
if (m_peer_list) m_peer_list->connection_closed(*p, m_ses.session_time(), &st);
|
||||
peers_erased(st.erased);
|
||||
|
||||
p->set_peer_info(0);
|
||||
p->set_peer_info(nullptr);
|
||||
TORRENT_ASSERT(i != m_connections.end());
|
||||
m_connections.erase(i);
|
||||
|
||||
|
@ -5826,7 +5826,7 @@ namespace libtorrent
|
|||
// that's part of the web_seed_t we're about to remove
|
||||
TORRENT_ASSERT(peer->m_in_use == 1337);
|
||||
peer->disconnect(boost::asio::error::operation_aborted, op_bittorrent);
|
||||
peer->set_peer_info(0);
|
||||
peer->set_peer_info(nullptr);
|
||||
}
|
||||
if (has_picker()) picker().clear_peer(&web->peer_info);
|
||||
|
||||
|
@ -6138,7 +6138,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
TORRENT_ASSERT(web->resolving == false);
|
||||
TORRENT_ASSERT(web->peer_info.connection == 0);
|
||||
TORRENT_ASSERT(web->peer_info.connection == nullptr);
|
||||
|
||||
if (a.address().is_v4())
|
||||
{
|
||||
|
@ -6153,7 +6153,7 @@ namespace libtorrent
|
|||
= boost::make_shared<socket_type>(boost::ref(m_ses.get_io_service()));
|
||||
if (!s) return;
|
||||
|
||||
void* userdata = 0;
|
||||
void* userdata = nullptr;
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
const bool ssl = string_begins_no_case("https://", web->url.c_str());
|
||||
if (ssl)
|
||||
|
@ -6163,7 +6163,7 @@ namespace libtorrent
|
|||
}
|
||||
#endif
|
||||
bool ret = instantiate_connection(m_ses.get_io_service(), m_ses.proxy()
|
||||
, *s, userdata, 0, true, false);
|
||||
, *s, userdata, nullptr, true, false);
|
||||
(void)ret;
|
||||
TORRENT_ASSERT(ret);
|
||||
|
||||
|
@ -6740,7 +6740,7 @@ namespace libtorrent
|
|||
: piece_size - (j * block_size());
|
||||
bool complete = bi.state == block_info::writing
|
||||
|| bi.state == block_info::finished;
|
||||
if (info[j].peer == 0)
|
||||
if (info[j].peer == nullptr)
|
||||
{
|
||||
bi.set_peer(tcp::endpoint());
|
||||
bi.bytes_progress = complete ? bi.block_size : 0;
|
||||
|
@ -6795,7 +6795,7 @@ namespace libtorrent
|
|||
TORRENT_UNUSED(ignore_limit);
|
||||
|
||||
TORRENT_ASSERT(peerinfo);
|
||||
TORRENT_ASSERT(peerinfo->connection == 0);
|
||||
TORRENT_ASSERT(peerinfo->connection == nullptr);
|
||||
|
||||
if (m_abort) return false;
|
||||
|
||||
|
@ -6860,7 +6860,7 @@ namespace libtorrent
|
|||
// this is where we determine if we open a regular TCP connection
|
||||
// or a uTP connection. If the utp_socket_manager pointer is not passed in
|
||||
// we'll instantiate a TCP connection
|
||||
utp_socket_manager* sm = 0;
|
||||
utp_socket_manager* sm = nullptr;
|
||||
|
||||
if (settings().get_bool(settings_pack::enable_outgoing_utp)
|
||||
&& (!settings().get_bool(settings_pack::enable_outgoing_tcp)
|
||||
|
@ -6869,7 +6869,7 @@ namespace libtorrent
|
|||
sm = m_ses.utp_socket_manager();
|
||||
|
||||
// don't make a TCP connection if it's disabled
|
||||
if (sm == 0 && !settings().get_bool(settings_pack::enable_outgoing_tcp))
|
||||
if (sm == nullptr && !settings().get_bool(settings_pack::enable_outgoing_tcp))
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
debug_log("discarding peer \"%s\": TCP connections disabled "
|
||||
|
@ -6879,7 +6879,7 @@ namespace libtorrent
|
|||
return false;
|
||||
}
|
||||
|
||||
void* userdata = 0;
|
||||
void* userdata = nullptr;
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
if (is_ssl_torrent())
|
||||
{
|
||||
|
@ -7154,7 +7154,7 @@ namespace libtorrent
|
|||
}
|
||||
#endif // TORRENT_USE_OPENSSL
|
||||
|
||||
TORRENT_ASSERT(p != 0);
|
||||
TORRENT_ASSERT(p != nullptr);
|
||||
TORRENT_ASSERT(!p->is_outgoing());
|
||||
|
||||
m_has_incoming = true;
|
||||
|
@ -7648,7 +7648,7 @@ namespace libtorrent
|
|||
state_updated();
|
||||
|
||||
if (m_completed_time == 0)
|
||||
m_completed_time = time(0);
|
||||
m_completed_time = time(nullptr);
|
||||
|
||||
// disconnect all seeds
|
||||
if (settings().get_bool(settings_pack::close_redundant_connections))
|
||||
|
@ -8211,7 +8211,7 @@ namespace libtorrent
|
|||
|
||||
if (!p.is_choked() && !p.ignore_unchoke_slots()) ++num_uploads;
|
||||
torrent* associated_torrent = p.associated_torrent().lock().get();
|
||||
if (associated_torrent != this && associated_torrent != 0)
|
||||
if (associated_torrent != this && associated_torrent != nullptr)
|
||||
TORRENT_ASSERT_FAIL();
|
||||
}
|
||||
TORRENT_ASSERT(num_uploads == int(m_num_uploads));
|
||||
|
@ -10303,7 +10303,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(i->resolving == false);
|
||||
|
||||
TORRENT_ASSERT(i->peer_info.connection);
|
||||
i->peer_info.connection = 0;
|
||||
i->peer_info.connection = nullptr;
|
||||
}
|
||||
|
||||
void torrent::remove_web_seed_conn(peer_connection* p, error_code const& ec
|
||||
|
@ -10324,7 +10324,7 @@ namespace libtorrent
|
|||
// that's part of the web_seed_t we're about to remove
|
||||
TORRENT_ASSERT(peer->m_in_use == 1337);
|
||||
peer->disconnect(ec, op, error);
|
||||
peer->set_peer_info(0);
|
||||
peer->set_peer_info(nullptr);
|
||||
}
|
||||
remove_web_seed_iter(i);
|
||||
}
|
||||
|
@ -10569,7 +10569,7 @@ namespace libtorrent
|
|||
std::vector<announce_entry>::iterator i = std::find_if(
|
||||
m_trackers.begin(), m_trackers.end()
|
||||
, [&r] (announce_entry const& ae) { return ae.url == r.url; });
|
||||
if (i == m_trackers.end()) return 0;
|
||||
if (i == m_trackers.end()) return nullptr;
|
||||
return &*i;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace libtorrent
|
|||
static const char invalid_chars[] = "";
|
||||
#endif
|
||||
if (c >= 0 && c < 32) return false;
|
||||
return std::strchr(invalid_chars, c) == 0;
|
||||
return std::strchr(invalid_chars, c) == nullptr;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -985,7 +985,7 @@ namespace libtorrent
|
|||
if (m_orig_files) m_orig_files.reset();
|
||||
else m_files.unload();
|
||||
|
||||
m_piece_hashes = 0;
|
||||
m_piece_hashes = nullptr;
|
||||
std::vector<web_seed_entry>().swap(m_web_seeds);
|
||||
|
||||
TORRENT_ASSERT(!is_loaded());
|
||||
|
@ -1299,7 +1299,7 @@ namespace libtorrent
|
|||
ret[sibling] = m_merkle_tree[sibling];
|
||||
// we cannot build the tree path if one
|
||||
// of the nodes in the tree is missing
|
||||
TORRENT_ASSERT(m_merkle_tree[sibling] != sha1_hash(0));
|
||||
TORRENT_ASSERT(m_merkle_tree[sibling] != sha1_hash(nullptr));
|
||||
n = parent;
|
||||
}
|
||||
return ret;
|
||||
|
@ -1632,7 +1632,7 @@ namespace libtorrent
|
|||
{
|
||||
for (int i = 0; i < m_files.num_files(); ++i)
|
||||
{
|
||||
TORRENT_ASSERT(m_files.file_name_ptr(i) != 0);
|
||||
TORRENT_ASSERT(m_files.file_name_ptr(i) != nullptr);
|
||||
if (m_files.file_name_len(i) != -1)
|
||||
{
|
||||
// name needs to point into the allocated info section buffer
|
||||
|
@ -1646,7 +1646,7 @@ namespace libtorrent
|
|||
}
|
||||
}
|
||||
|
||||
if (m_piece_hashes != 0)
|
||||
if (m_piece_hashes != nullptr)
|
||||
{
|
||||
TORRENT_ASSERT(m_piece_hashes >= m_info_section.get());
|
||||
TORRENT_ASSERT(m_piece_hashes < m_info_section.get() + m_info_section_size);
|
||||
|
|
|
@ -144,7 +144,7 @@ namespace libtorrent
|
|||
torrent_peer::torrent_peer(std::uint16_t port_, bool conn, int src)
|
||||
: prev_amount_upload(0)
|
||||
, prev_amount_download(0)
|
||||
, connection(0)
|
||||
, connection(nullptr)
|
||||
, peer_rank(0)
|
||||
, last_optimistically_unchoked(0)
|
||||
, last_connected(0)
|
||||
|
@ -206,7 +206,7 @@ namespace libtorrent
|
|||
|
||||
std::uint64_t torrent_peer::total_download() const
|
||||
{
|
||||
if (connection != 0)
|
||||
if (connection != nullptr)
|
||||
{
|
||||
TORRENT_ASSERT(prev_amount_download == 0);
|
||||
return connection->statistics().total_payload_download();
|
||||
|
@ -219,7 +219,7 @@ namespace libtorrent
|
|||
|
||||
std::uint64_t torrent_peer::total_upload() const
|
||||
{
|
||||
if (connection != 0)
|
||||
if (connection != nullptr)
|
||||
{
|
||||
TORRENT_ASSERT(prev_amount_upload == 0);
|
||||
return connection->statistics().total_payload_upload();
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace libtorrent
|
|||
, announcing_to_lsd(false)
|
||||
, announcing_to_dht(false)
|
||||
, stop_when_ready(false)
|
||||
, info_hash(0)
|
||||
, info_hash(nullptr)
|
||||
{}
|
||||
|
||||
torrent_status::~torrent_status() {}
|
||||
|
|
|
@ -1152,7 +1152,7 @@ struct upnp_error_category : boost::system::error_category
|
|||
{
|
||||
int num_errors = sizeof(error_codes) / sizeof(error_codes[0]);
|
||||
error_code_t* end = error_codes + num_errors;
|
||||
error_code_t tmp = {ev, 0};
|
||||
error_code_t tmp = {ev, nullptr};
|
||||
error_code_t* e = std::lower_bound(error_codes, end, tmp
|
||||
, [] (error_code_t const& lhs, error_code_t const& rhs)
|
||||
{ return lhs.code < rhs.code; });
|
||||
|
@ -1416,7 +1416,7 @@ void upnp::return_error(int mapping, int code)
|
|||
TORRENT_ASSERT(is_single_thread());
|
||||
int num_errors = sizeof(error_codes) / sizeof(error_codes[0]);
|
||||
error_code_t* end = error_codes + num_errors;
|
||||
error_code_t tmp = {code, 0};
|
||||
error_code_t tmp = {code, nullptr};
|
||||
error_code_t* e = std::lower_bound(error_codes, end, tmp
|
||||
, [] (error_code_t const& lhs, error_code_t const& rhs)
|
||||
{ return lhs.code < rhs.code; });
|
||||
|
|
|
@ -284,7 +284,7 @@ namespace libtorrent { namespace
|
|||
e["msg_type"] = type;
|
||||
e["piece"] = piece;
|
||||
|
||||
char const* metadata = 0;
|
||||
char const* metadata = nullptr;
|
||||
int metadata_piece_size = 0;
|
||||
|
||||
if (m_torrent.valid_metadata())
|
||||
|
@ -360,8 +360,8 @@ namespace libtorrent { namespace
|
|||
|
||||
entry const* type_ent = msg.find_key("msg_type");
|
||||
entry const* piece_ent = msg.find_key("piece");
|
||||
if (type_ent == 0 || type_ent->type() != entry::int_t
|
||||
|| piece_ent == 0 || piece_ent->type() != entry::int_t)
|
||||
if (type_ent == nullptr || type_ent->type() != entry::int_t
|
||||
|| piece_ent == nullptr || piece_ent->type() != entry::int_t)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log(peer_log_alert::incoming_message, "UT_METADATA"
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace libtorrent
|
|||
, void* ssl_context)
|
||||
: m_send_fun(send_fun)
|
||||
, m_cb(cb)
|
||||
, m_last_socket(0)
|
||||
, m_last_socket(nullptr)
|
||||
, m_new_connection(-1)
|
||||
, m_sett(sett)
|
||||
, m_last_route_update(min_time())
|
||||
|
@ -88,7 +88,7 @@ namespace libtorrent
|
|||
if (should_delete(i->second))
|
||||
{
|
||||
delete_utp_impl(i->second);
|
||||
if (m_last_socket == i->second) m_last_socket = 0;
|
||||
if (m_last_socket == i->second) m_last_socket = nullptr;
|
||||
m_utp_sockets.erase(i++);
|
||||
continue;
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ namespace libtorrent
|
|||
socket_map_t::iterator i = m_utp_sockets.find(id);
|
||||
if (i == m_utp_sockets.end()) return;
|
||||
delete_utp_impl(i->second);
|
||||
if (m_last_socket == i->second) m_last_socket = 0;
|
||||
if (m_last_socket == i->second) m_last_socket = nullptr;
|
||||
m_utp_sockets.erase(i);
|
||||
}
|
||||
|
||||
|
|
|
@ -834,7 +834,7 @@ int utp_stream::recv_delay() const
|
|||
|
||||
utp_stream::utp_stream(io_service& io_service)
|
||||
: m_io_service(io_service)
|
||||
, m_impl(0)
|
||||
, m_impl(nullptr)
|
||||
, m_incoming_close_reason(0)
|
||||
, m_open(false)
|
||||
{
|
||||
|
@ -863,7 +863,7 @@ void utp_stream::close()
|
|||
{
|
||||
if (!m_impl) return;
|
||||
detach_utp_impl(m_impl);
|
||||
m_impl = 0;
|
||||
m_impl = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -884,7 +884,7 @@ utp_stream::endpoint_type utp_stream::remote_endpoint(error_code& ec) const
|
|||
|
||||
utp_stream::endpoint_type utp_stream::local_endpoint(error_code& ec) const
|
||||
{
|
||||
if (m_impl == 0 || m_impl->m_sm == 0)
|
||||
if (m_impl == nullptr || m_impl->m_sm == nullptr)
|
||||
{
|
||||
ec = boost::asio::error::not_connected;
|
||||
}
|
||||
|
@ -900,12 +900,12 @@ utp_stream::~utp_stream()
|
|||
detach_utp_impl(m_impl);
|
||||
}
|
||||
|
||||
m_impl = 0;
|
||||
m_impl = nullptr;
|
||||
}
|
||||
|
||||
void utp_stream::set_impl(utp_socket_impl* impl)
|
||||
{
|
||||
TORRENT_ASSERT(m_impl == 0);
|
||||
TORRENT_ASSERT(m_impl == nullptr);
|
||||
TORRENT_ASSERT(!m_open);
|
||||
m_impl = impl;
|
||||
m_open = true;
|
||||
|
@ -945,7 +945,7 @@ void utp_stream::on_read(void* self, size_t bytes_transferred
|
|||
{
|
||||
TORRENT_ASSERT(ec);
|
||||
detach_utp_impl(s->m_impl);
|
||||
s->m_impl = 0;
|
||||
s->m_impl = nullptr;
|
||||
}
|
||||
// tmp(ec, bytes_transferred);
|
||||
}
|
||||
|
@ -969,7 +969,7 @@ void utp_stream::on_write(void* self, size_t bytes_transferred
|
|||
{
|
||||
TORRENT_ASSERT(ec);
|
||||
detach_utp_impl(s->m_impl);
|
||||
s->m_impl = 0;
|
||||
s->m_impl = nullptr;
|
||||
}
|
||||
// tmp(ec, bytes_transferred);
|
||||
}
|
||||
|
@ -991,7 +991,7 @@ void utp_stream::on_connect(void* self, error_code const& ec, bool kill)
|
|||
{
|
||||
TORRENT_ASSERT(ec);
|
||||
detach_utp_impl(s->m_impl);
|
||||
s->m_impl = 0;
|
||||
s->m_impl = nullptr;
|
||||
}
|
||||
// tmp(ec);
|
||||
}
|
||||
|
@ -1125,7 +1125,7 @@ size_t utp_stream::read_some(bool clear_buffers)
|
|||
{
|
||||
free(p);
|
||||
++pop_packets;
|
||||
*i = 0;
|
||||
*i = nullptr;
|
||||
++i;
|
||||
}
|
||||
|
||||
|
@ -1314,14 +1314,14 @@ bool utp_socket_impl::destroy()
|
|||
, static_cast<void*>(this), socket_state_names[m_state], int(m_close_reason));
|
||||
#endif
|
||||
|
||||
if (m_userdata == 0) return false;
|
||||
if (m_userdata == nullptr) return false;
|
||||
|
||||
if (m_state == UTP_STATE_CONNECTED)
|
||||
send_fin();
|
||||
|
||||
bool cancelled = cancel_handlers(boost::asio::error::operation_aborted, true);
|
||||
|
||||
m_userdata = 0;
|
||||
m_userdata = nullptr;
|
||||
|
||||
m_read_buffer.clear();
|
||||
m_read_buffer_size = 0;
|
||||
|
@ -1512,7 +1512,7 @@ void utp_socket_impl::parse_close_reason(std::uint8_t const* ptr, int size)
|
|||
UTP_LOGV("%8p: incoming close_reason: %d\n"
|
||||
, static_cast<void*>(this), int(incoming_close_reason));
|
||||
|
||||
if (m_userdata == 0) return;
|
||||
if (m_userdata == nullptr) return;
|
||||
|
||||
utp_stream::on_close_reason(m_userdata, incoming_close_reason);
|
||||
}
|
||||
|
@ -2373,7 +2373,7 @@ void utp_socket_impl::maybe_inc_acked_seq_nr()
|
|||
// if the slot in m_outbuf is 0, it means the
|
||||
// packet has been ACKed and removed from the send buffer
|
||||
while (((m_acked_seq_nr + 1) & ACK_MASK) != m_seq_nr
|
||||
&& m_outbuf.at((m_acked_seq_nr + 1) & ACK_MASK) == 0)
|
||||
&& m_outbuf.at((m_acked_seq_nr + 1) & ACK_MASK) == nullptr)
|
||||
{
|
||||
// increment the fast resend sequence number
|
||||
if (m_fast_resend_seq_nr == m_acked_seq_nr)
|
||||
|
@ -2478,7 +2478,7 @@ void utp_socket_impl::incoming(std::uint8_t const* buf, int size, packet* p
|
|||
|
||||
if (size == 0)
|
||||
{
|
||||
TORRENT_ASSERT(p == 0 || p->header_size == p->size);
|
||||
TORRENT_ASSERT(p == nullptr || p->header_size == p->size);
|
||||
free(p);
|
||||
return;
|
||||
}
|
||||
|
@ -2558,7 +2558,7 @@ bool utp_socket_impl::consume_incoming_data(
|
|||
|
||||
if (ph->seq_nr == ((m_ack_nr + 1) & ACK_MASK))
|
||||
{
|
||||
TORRENT_ASSERT(m_inbuf.at(m_ack_nr) == 0);
|
||||
TORRENT_ASSERT(m_inbuf.at(m_ack_nr) == nullptr);
|
||||
|
||||
if (m_buffered_incoming_bytes + m_receive_buffer_size + payload_size > m_in_buf_size)
|
||||
{
|
||||
|
@ -2568,12 +2568,12 @@ bool utp_socket_impl::consume_incoming_data(
|
|||
}
|
||||
|
||||
// we received a packet in order
|
||||
incoming(ptr, payload_size, 0, now);
|
||||
incoming(ptr, payload_size, nullptr, now);
|
||||
m_ack_nr = (m_ack_nr + 1) & ACK_MASK;
|
||||
|
||||
// If this packet was previously in the reorder buffer
|
||||
// it would have been acked when m_ack_nr-1 was acked.
|
||||
TORRENT_ASSERT(m_inbuf.at(m_ack_nr) == 0);
|
||||
TORRENT_ASSERT(m_inbuf.at(m_ack_nr) == nullptr);
|
||||
|
||||
UTP_LOGV("%8p: remove inbuf: %d (%d)\n"
|
||||
, static_cast<void*>(this), m_ack_nr, int(m_inbuf.size()));
|
||||
|
@ -2587,7 +2587,7 @@ bool utp_socket_impl::consume_incoming_data(
|
|||
if (!p) break;
|
||||
|
||||
m_buffered_incoming_bytes -= p->size - p->header_size;
|
||||
incoming(0, p->size - p->header_size, p, now);
|
||||
incoming(nullptr, p->size - p->header_size, p, now);
|
||||
|
||||
m_ack_nr = next_ack_nr;
|
||||
|
||||
|
|
|
@ -74,12 +74,12 @@ bool keep_files = false;
|
|||
extern int _g_test_idx;
|
||||
|
||||
// the current tests file descriptor
|
||||
unit_test_t* current_test = NULL;
|
||||
unit_test_t* current_test = nullptr;
|
||||
|
||||
void output_test_log_to_terminal()
|
||||
{
|
||||
if (current_test == NULL || old_stdout == -1 || old_stderr == -1
|
||||
|| !redirect_output || current_test->output == NULL)
|
||||
if (current_test == nullptr || old_stdout == -1 || old_stderr == -1
|
||||
|| !redirect_output || current_test->output == nullptr)
|
||||
return;
|
||||
|
||||
fflush(stdout);
|
||||
|
@ -347,7 +347,7 @@ EXPORT int main(int argc, char const* argv[])
|
|||
fflush(stderr);
|
||||
|
||||
FILE* f = tmpfile();
|
||||
if (f != NULL)
|
||||
if (f != nullptr)
|
||||
{
|
||||
int ret1 = dup2(fileno(f), fileno(stdout));
|
||||
dup2(fileno(f), fileno(stderr));
|
||||
|
@ -369,8 +369,8 @@ EXPORT int main(int argc, char const* argv[])
|
|||
}
|
||||
|
||||
// get proper interleaving of stderr and stdout
|
||||
setbuf(stdout, NULL);
|
||||
setbuf(stderr, NULL);
|
||||
setbuf(stdout, nullptr);
|
||||
setbuf(stderr, nullptr);
|
||||
|
||||
_g_test_idx = i;
|
||||
current_test = &t;
|
||||
|
|
|
@ -41,7 +41,7 @@ void print_alerts(libtorrent::session* ses, libtorrent::time_point start_time)
|
|||
using namespace libtorrent;
|
||||
namespace lt = libtorrent;
|
||||
|
||||
if (ses == NULL) return;
|
||||
if (ses == nullptr) return;
|
||||
|
||||
std::vector<lt::alert*> alerts;
|
||||
ses->pop_alerts(&alerts);
|
||||
|
|
|
@ -177,9 +177,9 @@ alert const* wait_for_alert(lt::session& ses, int type, char const* name)
|
|||
while (true)
|
||||
{
|
||||
time_point now = clock_type::now();
|
||||
if (now > end_time) return NULL;
|
||||
if (now > end_time) return nullptr;
|
||||
|
||||
alert const* ret = NULL;
|
||||
alert const* ret = nullptr;
|
||||
|
||||
ses.wait_for_alert(end_time - now);
|
||||
std::vector<alert*> alerts;
|
||||
|
@ -198,14 +198,14 @@ alert const* wait_for_alert(lt::session& ses, int type, char const* name)
|
|||
}
|
||||
if (ret) return ret;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int load_file(std::string const& filename, std::vector<char>& v, libtorrent::error_code& ec, int limit)
|
||||
{
|
||||
ec.clear();
|
||||
FILE* f = fopen(filename.c_str(), "rb");
|
||||
if (f == NULL)
|
||||
if (f == nullptr)
|
||||
{
|
||||
ec.assign(errno, boost::system::system_category());
|
||||
return -1;
|
||||
|
@ -307,7 +307,7 @@ bool print_alerts(lt::session& ses, char const* name
|
|||
std::fprintf(stderr, "%s: %s: [%s] %s\n", time_now_string(), name, (a)->what(), (a)->message().c_str());
|
||||
}
|
||||
|
||||
TEST_CHECK(alert_cast<fastresume_rejected_alert>(a) == 0 || allow_failed_fastresume);
|
||||
TEST_CHECK(alert_cast<fastresume_rejected_alert>(a) == nullptr || allow_failed_fastresume);
|
||||
/*
|
||||
peer_error_alert const* pea = alert_cast<peer_error_alert>(a);
|
||||
if (pea)
|
||||
|
@ -349,7 +349,7 @@ bool listen_alert(libtorrent::alert const* a)
|
|||
void wait_for_listen(lt::session& ses, char const* name)
|
||||
{
|
||||
listen_done = false;
|
||||
alert const* a = 0;
|
||||
alert const* a = nullptr;
|
||||
do
|
||||
{
|
||||
print_alerts(ses, name, true, true, true, &listen_alert, false);
|
||||
|
@ -373,7 +373,7 @@ void wait_for_downloading(lt::session& ses, char const* name)
|
|||
{
|
||||
time_point start = clock_type::now();
|
||||
downloading_done = false;
|
||||
alert const* a = 0;
|
||||
alert const* a = nullptr;
|
||||
do
|
||||
{
|
||||
print_alerts(ses, name, true, true, true, &downloading_alert, false);
|
||||
|
@ -488,9 +488,9 @@ pid_type async_run(char const* cmdline)
|
|||
argv.push_back(argp);
|
||||
}
|
||||
*argp = '\0';
|
||||
argv.push_back(NULL);
|
||||
argv.push_back(nullptr);
|
||||
|
||||
int ret = posix_spawnp(&p, argv[0], NULL, NULL, &argv[0], NULL);
|
||||
int ret = posix_spawnp(&p, argv[0], nullptr, nullptr, &argv[0], nullptr);
|
||||
if (ret != 0)
|
||||
{
|
||||
std::fprintf(stderr, "failed (%d) %s\n", errno, strerror(errno));
|
||||
|
@ -764,7 +764,7 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3
|
|||
if (ses3) TORRENT_ASSERT(ses3->id() != ses2->id());
|
||||
|
||||
boost::shared_ptr<torrent_info> t;
|
||||
if (torrent == 0)
|
||||
if (torrent == nullptr)
|
||||
{
|
||||
error_code ec;
|
||||
create_directory("tmp1" + suffix, ec);
|
||||
|
|
|
@ -131,7 +131,7 @@ void test_swarm(int flags)
|
|||
if (flags & seed_mode) p.flags |= add_torrent_params::flag_seed_mode;
|
||||
// test using piece sizes smaller than 16kB
|
||||
std::tie(tor1, tor2, tor3) = setup_transfer(&ses1, &ses2, &ses3, true
|
||||
, false, true, "_swarm", 8 * 1024, 0, flags & super_seeding, &p);
|
||||
, false, true, "_swarm", 8 * 1024, nullptr, flags & super_seeding, &p);
|
||||
|
||||
if (flags & time_critical)
|
||||
{
|
||||
|
@ -197,7 +197,7 @@ void test_swarm(int flags)
|
|||
|
||||
alert const* a = wait_for_alert(ses1, torrent_deleted_alert::alert_type, "swarm_suite");
|
||||
|
||||
TEST_CHECK(alert_cast<torrent_deleted_alert>(a) != 0);
|
||||
TEST_CHECK(alert_cast<torrent_deleted_alert>(a) != nullptr);
|
||||
|
||||
// there shouldn't be any alerts generated from now on
|
||||
// make sure that the timer in wait_for_alert() works
|
||||
|
|
|
@ -207,7 +207,7 @@ TORRENT_TEST(wait_for_alert)
|
|||
alert* a = mgr.wait_for_alert(seconds(1));
|
||||
|
||||
time_point end = clock_type::now();
|
||||
TEST_EQUAL(a, static_cast<alert*>(0));
|
||||
TEST_EQUAL(a, static_cast<alert*>(nullptr));
|
||||
std::fprintf(stderr, "delay: %d ms (expected 1 second)\n"
|
||||
, int(total_milliseconds(end - start)));
|
||||
TEST_CHECK(end - start > milliseconds(900));
|
||||
|
|
|
@ -420,7 +420,7 @@ TORRENT_TEST(depth_limit)
|
|||
|
||||
bdecode_node e;
|
||||
error_code ec;
|
||||
int ret = bdecode(b, b + sizeof(b), e, ec, NULL, 100);
|
||||
int ret = bdecode(b, b + sizeof(b), e, ec, nullptr, 100);
|
||||
TEST_CHECK(ret != 0);
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::depth_exceeded
|
||||
, get_bdecode_category()));
|
||||
|
@ -438,7 +438,7 @@ TORRENT_TEST(item_limit)
|
|||
|
||||
bdecode_node e;
|
||||
error_code ec;
|
||||
int ret = bdecode(b, b + i + 1, e, ec, NULL, 1000, 1000);
|
||||
int ret = bdecode(b, b + i + 1, e, ec, nullptr, 1000, 1000);
|
||||
TEST_CHECK(ret != 0);
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::limit_exceeded
|
||||
, get_bdecode_category()));
|
||||
|
@ -588,7 +588,7 @@ TORRENT_TEST(empty_string)
|
|||
|
||||
bdecode_node e;
|
||||
error_code ec;
|
||||
int ret = bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_EQUAL(ret, -1);
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof));
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
|
|
|
@ -338,7 +338,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + i + 1, e, ec, NULL, 1000, 1000);
|
||||
int ret = lazy_bdecode(b, b + i + 1, e, ec, nullptr, 1000, 1000);
|
||||
TEST_CHECK(ret != 0);
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::limit_exceeded
|
||||
, get_bdecode_category()));
|
||||
|
@ -350,7 +350,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_CHECK(ret != 0);
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof
|
||||
|
@ -363,7 +363,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_CHECK(ret != 0);
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof
|
||||
|
@ -377,7 +377,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_CHECK(ret != 0);
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::expected_digit
|
||||
|
@ -390,7 +390,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_CHECK(ret != 0);
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof
|
||||
|
@ -403,7 +403,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_CHECK(ret != 0);
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof
|
||||
|
@ -416,7 +416,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_CHECK(ret != 0);
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::expected_digit
|
||||
|
@ -429,7 +429,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_CHECK(ret != 0);
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof
|
||||
|
@ -442,7 +442,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_CHECK(ret != 0);
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof
|
||||
|
@ -456,7 +456,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_CHECK(ret != 0);
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::expected_colon
|
||||
|
@ -469,7 +469,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_EQUAL(ret, -1);
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof
|
||||
, get_bdecode_category()));
|
||||
|
@ -482,7 +482,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_CHECK(ret != 0);
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
TEST_EQUAL(ec, error_code(bdecode_errors::unexpected_eof
|
||||
|
@ -495,7 +495,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_EQUAL(ret, 0);
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
|
||||
|
@ -504,7 +504,7 @@ TORRENT_TEST(lazy_entry)
|
|||
TEST_EQUAL(ps.len, 6);
|
||||
|
||||
ps = e.dict_find_pstr("foobar2");
|
||||
TEST_EQUAL(ps.ptr, static_cast<char const*>(0));
|
||||
TEST_EQUAL(ps.ptr, static_cast<char const*>(nullptr));
|
||||
TEST_EQUAL(ps.len, 0);
|
||||
}
|
||||
|
||||
|
@ -514,7 +514,7 @@ TORRENT_TEST(lazy_entry)
|
|||
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, NULL);
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e, ec, nullptr);
|
||||
TEST_EQUAL(ret, 0);
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
|
||||
|
@ -524,7 +524,7 @@ TORRENT_TEST(lazy_entry)
|
|||
TEST_EQUAL(ps.len, 6);
|
||||
|
||||
ps = e.list_pstr_at(1);
|
||||
TEST_EQUAL(ps.ptr, static_cast<char const*>(0));
|
||||
TEST_EQUAL(ps.ptr, static_cast<char const*>(nullptr));
|
||||
TEST_EQUAL(ps.len, 0);
|
||||
}
|
||||
|
||||
|
@ -634,7 +634,7 @@ TORRENT_TEST(lazy_entry)
|
|||
{
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode(b[i], b[i] + strlen(b[i]), e, ec, NULL);
|
||||
int ret = lazy_bdecode(b[i], b[i] + strlen(b[i]), e, ec, nullptr);
|
||||
TEST_EQUAL(ret, -1);
|
||||
TEST_CHECK(ec == error_code(bdecode_errors::unexpected_eof));
|
||||
std::printf("%s\n", print_entry(e).c_str());
|
||||
|
|
|
@ -437,7 +437,7 @@ void test_unaligned_read()
|
|||
rj.piece = 0;
|
||||
rj.storage = pm;
|
||||
rj.requester = (void*)1;
|
||||
rj.buffer.disk_block = 0;
|
||||
rj.buffer.disk_block = nullptr;
|
||||
ret = bc.try_read(&rj);
|
||||
|
||||
// unaligned reads copies the data into a new buffer
|
||||
|
|
|
@ -214,7 +214,7 @@ TORRENT_TEST(chained_buffer)
|
|||
TEST_CHECK(!b.empty());
|
||||
TEST_CHECK(b.space_in_last_buffer() == 512 - 6);
|
||||
|
||||
bool ret = b.append(data, 6) != NULL;
|
||||
bool ret = b.append(data, 6) != nullptr;
|
||||
|
||||
TEST_CHECK(ret == true);
|
||||
TEST_CHECK(b.capacity() == 512);
|
||||
|
@ -223,7 +223,7 @@ TORRENT_TEST(chained_buffer)
|
|||
TEST_CHECK(b.space_in_last_buffer() == 512 - 12);
|
||||
|
||||
char data2[1024];
|
||||
ret = b.append(data2, 1024) != NULL;
|
||||
ret = b.append(data2, 1024) != nullptr;
|
||||
|
||||
TEST_CHECK(ret == false);
|
||||
|
||||
|
@ -272,11 +272,11 @@ TORRENT_TEST(chained_buffer)
|
|||
b.append_buffer(b4, 20, 12, &free_buffer, (void*)0x1337);
|
||||
TEST_CHECK(b.space_in_last_buffer() == 8);
|
||||
|
||||
ret = b.append(data, 6) != NULL;
|
||||
ret = b.append(data, 6) != nullptr;
|
||||
TEST_CHECK(ret == true);
|
||||
TEST_CHECK(b.space_in_last_buffer() == 2);
|
||||
std::cout << b.space_in_last_buffer() << std::endl;
|
||||
ret = b.append(data, 2) != NULL;
|
||||
ret = b.append(data, 2) != nullptr;
|
||||
TEST_CHECK(ret == true);
|
||||
TEST_CHECK(b.space_in_last_buffer() == 0);
|
||||
std::cout << b.space_in_last_buffer() << std::endl;
|
||||
|
|
|
@ -58,7 +58,7 @@ TORRENT_TEST(create_verbatim_torrent)
|
|||
buffer.push_back('\0');
|
||||
char const* dest_info = std::strstr(&buffer[0], "4:info");
|
||||
|
||||
TEST_CHECK(dest_info != NULL);
|
||||
TEST_CHECK(dest_info != nullptr);
|
||||
|
||||
// +1 and -2 here is to strip the outermost dictionary from the source
|
||||
// torrent, since create_torrent may have added items next to the info dict
|
||||
|
|
|
@ -509,11 +509,11 @@ void do_test_dht(address(&rand_addr)())
|
|||
obs observer;
|
||||
counters cnt;
|
||||
std::unique_ptr<dht_storage_interface> dht_storage(dht_default_storage_constructor(sett));
|
||||
dht_storage->update_node_ids({node_id(0)});
|
||||
dht_storage->update_node_ids({node_id(nullptr)});
|
||||
udp::endpoint source(rand_addr(), 20);
|
||||
std::map<std::string, node*> nodes;
|
||||
dht::node node(source.protocol(), &s, sett
|
||||
, node_id(0), &observer, cnt, nodes, *dht_storage);
|
||||
, node_id(nullptr), &observer, cnt, nodes, *dht_storage);
|
||||
|
||||
// DHT should be running on port 48199 now
|
||||
bdecode_node response;
|
||||
|
@ -905,7 +905,7 @@ void do_test_dht(address(&rand_addr)())
|
|||
|
||||
std::pair<char const*, int> itemv;
|
||||
std::pair<char const*, int> empty_salt;
|
||||
empty_salt.first = NULL;
|
||||
empty_salt.first = nullptr;
|
||||
empty_salt.second = 0;
|
||||
|
||||
char signature[item_sig_len];
|
||||
|
@ -928,7 +928,7 @@ void do_test_dht(address(&rand_addr)())
|
|||
|
||||
TEST_CHECK(ret);
|
||||
|
||||
std::pair<const char*, int> salt((char*)0, 0);
|
||||
std::pair<const char*, int> salt((char*)nullptr, 0);
|
||||
if (with_salt)
|
||||
salt = std::pair<char const*, int>("foobar", 6);
|
||||
|
||||
|
@ -2040,9 +2040,9 @@ TORRENT_TEST(dht_dual_stack)
|
|||
counters cnt;
|
||||
std::map<std::string, node*> nodes;
|
||||
std::unique_ptr<dht_storage_interface> dht_storage(dht_default_storage_constructor(sett));
|
||||
dht_storage->update_node_ids({node_id(0)});
|
||||
dht::node node4(udp::v4(), &s, sett, node_id(0), &observer, cnt, nodes, *dht_storage);
|
||||
dht::node node6(udp::v6(), &s, sett, node_id(0), &observer, cnt, nodes, *dht_storage);
|
||||
dht_storage->update_node_ids({node_id(nullptr)});
|
||||
dht::node node4(udp::v4(), &s, sett, node_id(nullptr), &observer, cnt, nodes, *dht_storage);
|
||||
dht::node node6(udp::v6(), &s, sett, node_id(nullptr), &observer, cnt, nodes, *dht_storage);
|
||||
nodes.insert(std::make_pair("n4", &node4));
|
||||
nodes.insert(std::make_pair("n6", &node6));
|
||||
|
||||
|
@ -2502,8 +2502,8 @@ TORRENT_TEST(read_only_node)
|
|||
std::map<std::string, node*> nodes;
|
||||
|
||||
std::unique_ptr<dht_storage_interface> dht_storage(dht_default_storage_constructor(sett));
|
||||
dht_storage->update_node_ids({node_id(0)});
|
||||
dht::node node(udp::v4(), &s, sett, node_id(0), &observer, cnt, nodes, *dht_storage);
|
||||
dht_storage->update_node_ids({node_id(nullptr)});
|
||||
dht::node node(udp::v4(), &s, sett, node_id(nullptr), &observer, cnt, nodes, *dht_storage);
|
||||
udp::endpoint source(address::from_string("10.0.0.1"), 20);
|
||||
bdecode_node response;
|
||||
msg_args args;
|
||||
|
@ -2593,8 +2593,8 @@ TORRENT_TEST(invalid_error_msg)
|
|||
std::map<std::string, node*> nodes;
|
||||
|
||||
std::unique_ptr<dht_storage_interface> dht_storage(dht_default_storage_constructor(sett));
|
||||
dht_storage->update_node_ids({node_id(0)});
|
||||
dht::node node(udp::v4(), &s, sett, node_id(0), &observer, cnt, nodes, *dht_storage);
|
||||
dht_storage->update_node_ids({node_id(nullptr)});
|
||||
dht::node node(udp::v4(), &s, sett, node_id(nullptr), &observer, cnt, nodes, *dht_storage);
|
||||
udp::endpoint source(address::from_string("10.0.0.1"), 20);
|
||||
|
||||
entry e;
|
||||
|
@ -2635,8 +2635,8 @@ TORRENT_TEST(rpc_invalid_error_msg)
|
|||
dht::routing_table table(node_id(), udp::v4(), 8, sett, &observer);
|
||||
dht::rpc_manager rpc(node_id(), sett, table, &s, &observer);
|
||||
std::unique_ptr<dht_storage_interface> dht_storage(dht_default_storage_constructor(sett));
|
||||
dht_storage->update_node_ids({node_id(0)});
|
||||
dht::node node(udp::v4(), &s, sett, node_id(0), &observer, cnt, nodes, *dht_storage);
|
||||
dht_storage->update_node_ids({node_id(nullptr)});
|
||||
dht::node node(udp::v4(), &s, sett, node_id(nullptr), &observer, cnt, nodes, *dht_storage);
|
||||
|
||||
udp::endpoint source(address::from_string("10.0.0.1"), 20);
|
||||
|
||||
|
|
|
@ -316,7 +316,7 @@ TORRENT_TEST(update_node_ids)
|
|||
{
|
||||
dht_settings sett = test_settings();
|
||||
std::unique_ptr<dht_storage_interface> s(dht_default_storage_constructor(sett));
|
||||
TEST_CHECK(s.get() != NULL);
|
||||
TEST_CHECK(s.get() != nullptr);
|
||||
|
||||
node_id const n1 = to_hash("0000000000000000000000000000000000000200");
|
||||
node_id const n2 = to_hash("0000000000000000000000000000000000000400");
|
||||
|
|
|
@ -73,7 +73,7 @@ dht_direct_response_alert* get_direct_response(lt::session& ses)
|
|||
// it shouldn't take more than 20 seconds to get a response
|
||||
// so fail the test and bail out if we don't get an alert in that time
|
||||
TEST_CHECK(a);
|
||||
if (!a) return NULL;
|
||||
if (!a) return nullptr;
|
||||
std::vector<alert*> alerts;
|
||||
ses.pop_alerts(&alerts);
|
||||
for (std::vector<alert*>::iterator i = alerts.begin(); i != alerts.end(); ++i)
|
||||
|
|
|
@ -59,7 +59,7 @@ struct log_t : libtorrent::dht::dht_logger
|
|||
{
|
||||
libtorrent::bdecode_node print;
|
||||
libtorrent::error_code ec;
|
||||
int ret = bdecode(pkt, pkt + len, print, ec, NULL, 100, 100);
|
||||
int ret = bdecode(pkt, pkt + len, print, ec, nullptr, 100, 100);
|
||||
TEST_EQUAL(ret, 0);
|
||||
|
||||
std::string msg = print_entry(print, true);
|
||||
|
|
|
@ -406,7 +406,7 @@ 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
|
||||
, boost::shared_ptr<lt::session>& ses, bool incoming = true
|
||||
, int flags = 0, torrent_handle* th = NULL)
|
||||
, int flags = 0, torrent_handle* th = nullptr)
|
||||
{
|
||||
boost::shared_ptr<torrent_info> t = ::create_torrent();
|
||||
ih = t->info_hash();
|
||||
|
|
|
@ -143,7 +143,7 @@ void run_test(std::string const& url, int size, int status, int connected
|
|||
|
||||
void write_test_file()
|
||||
{
|
||||
std::srand(unsigned(std::time(0)));
|
||||
std::srand(unsigned(std::time(nullptr)));
|
||||
std::generate(data_buffer, data_buffer + sizeof(data_buffer), &std::rand);
|
||||
error_code ec;
|
||||
file test_file("test_file", file::write_only, ec);
|
||||
|
@ -206,7 +206,7 @@ void run_suite(std::string const& protocol
|
|||
hostent* h = gethostbyname("non-existent-domain.se");
|
||||
std::printf("gethostbyname(\"non-existent-domain.se\") = %p. h_errno = %d\n"
|
||||
, static_cast<void*>(h), h_errno);
|
||||
if (h == 0 && h_errno == HOST_NOT_FOUND)
|
||||
if (h == nullptr && h_errno == HOST_NOT_FOUND)
|
||||
{
|
||||
run_test(protocol + "://non-existent-domain.se/non-existing-file", -1, -1, 0, err(), ps);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ void compare(linked_list<test_node> const& list, int* array, int size)
|
|||
TEST_EQUAL(list.size(), size);
|
||||
|
||||
int idx = 0;
|
||||
for (test_node const* i = list.front(); i != NULL; i = i->next, ++idx)
|
||||
for (test_node const* i = list.front(); i != nullptr; i = i->next, ++idx)
|
||||
{
|
||||
TEST_EQUAL(i->val, array[idx]);
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ TORRENT_TEST(iterate_forward)
|
|||
it.next();
|
||||
TEST_EQUAL(it.get(), &n2);
|
||||
it.next();
|
||||
TEST_EQUAL(it.get(), static_cast<test_node*>(NULL));
|
||||
TEST_EQUAL(it.get(), static_cast<test_node*>(nullptr));
|
||||
}
|
||||
|
||||
TORRENT_TEST(iterate_backward)
|
||||
|
@ -193,6 +193,6 @@ TORRENT_TEST(iterate_backward)
|
|||
it.prev();
|
||||
TEST_EQUAL(it.get(), &n0);
|
||||
it.prev();
|
||||
TEST_EQUAL(it.get(), static_cast<test_node*>(NULL));
|
||||
TEST_EQUAL(it.get(), static_cast<test_node*>(nullptr));
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,8 @@ void test_lsd()
|
|||
torrent_handle tor2;
|
||||
|
||||
using std::ignore;
|
||||
std::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, 0, true, false, false, "_lsd"
|
||||
, 16 * 1024, 0, false, 0, false);
|
||||
std::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, nullptr, true, false, false, "_lsd"
|
||||
, 16 * 1024, nullptr, false, nullptr, false);
|
||||
|
||||
for (int i = 0; i < 30; ++i)
|
||||
{
|
||||
|
|
|
@ -118,7 +118,7 @@ TORRENT_TEST(wrap)
|
|||
TEST_CHECK(pb.at(2) == (void*)2);
|
||||
|
||||
pb.remove(0xfffe);
|
||||
TEST_CHECK(pb.at(0xfffe) == (void*)0);
|
||||
TEST_CHECK(pb.at(0xfffe) == (void*)nullptr);
|
||||
TEST_CHECK(pb.at(2) == (void*)2);
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ TORRENT_TEST(wrap2)
|
|||
|
||||
void* old = pb.remove(0xfff3);
|
||||
TEST_CHECK(old == (void*)1);
|
||||
TEST_CHECK(pb.at(0xfff3) == (void*)0);
|
||||
TEST_CHECK(pb.at(0xfff3) == (void*)nullptr);
|
||||
TEST_CHECK(pb.at(new_index) == (void*)2);
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ TORRENT_TEST(reverse_wrap)
|
|||
|
||||
void* old = pb.remove(0xfff3);
|
||||
TEST_CHECK(old == (void*)1);
|
||||
TEST_CHECK(pb.at(0xfff3) == (void*)0);
|
||||
TEST_CHECK(pb.at(0xfff3) == (void*)nullptr);
|
||||
TEST_CHECK(pb.at(new_index) == (void*)2);
|
||||
|
||||
pb.insert(0xffff, (void*)0xffff);
|
||||
|
|
|
@ -40,8 +40,8 @@ using namespace libtorrent;
|
|||
std::string class_name(peer_class_t id, peer_class_pool const& p)
|
||||
{
|
||||
peer_class const* c = p.at(id);
|
||||
TEST_CHECK(c != NULL);
|
||||
if (c == NULL) return "";
|
||||
TEST_CHECK(c != nullptr);
|
||||
if (c == nullptr) return "";
|
||||
peer_class_info i;
|
||||
c->get_info(&i);
|
||||
return i.label;
|
||||
|
@ -73,7 +73,7 @@ TORRENT_TEST(peer_class)
|
|||
TEST_CHECK(class_name(id3, pool) == "test3");
|
||||
pool.decref(id3);
|
||||
// it should have been deleted now
|
||||
TEST_CHECK(pool.at(id3) == NULL);
|
||||
TEST_CHECK(pool.at(id3) == nullptr);
|
||||
|
||||
// test setting and retrieving upload and download rates
|
||||
pool.at(id2)->set_upload_limit(1000);
|
||||
|
@ -110,7 +110,7 @@ TORRENT_TEST(peer_class)
|
|||
|
||||
pool.decref(id2);
|
||||
pool.decref(id1);
|
||||
TEST_CHECK(pool.at(id2) == NULL);
|
||||
TEST_CHECK(pool.at(id1) == NULL);
|
||||
TEST_CHECK(pool.at(id2) == nullptr);
|
||||
TEST_CHECK(pool.at(id1) == nullptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ struct mock_peer_connection
|
|||
mock_peer_connection(mock_torrent* tor, bool out, tcp::endpoint const& remote)
|
||||
: m_choked(false)
|
||||
, m_outgoing(out)
|
||||
, m_tp(NULL)
|
||||
, m_tp(nullptr)
|
||||
, m_remote(remote)
|
||||
, m_local(ep("127.0.0.1", 8080))
|
||||
, m_disconnect_called(false)
|
||||
|
@ -113,12 +113,12 @@ struct mock_peer_connection
|
|||
|
||||
struct mock_torrent
|
||||
{
|
||||
mock_torrent(torrent_state* st) : m_p(NULL), m_state(st) {}
|
||||
mock_torrent(torrent_state* st) : m_p(nullptr), m_state(st) {}
|
||||
virtual ~mock_torrent() {}
|
||||
|
||||
bool connect_to_peer(torrent_peer* peerinfo, bool ignore_limit = false)
|
||||
{
|
||||
TORRENT_ASSERT(peerinfo->connection == NULL);
|
||||
TORRENT_ASSERT(peerinfo->connection == nullptr);
|
||||
if (peerinfo->connection) return false;
|
||||
auto c = std::make_shared<mock_peer_connection>(this, true, peerinfo->ip());
|
||||
c->set_peer_info(peerinfo);
|
||||
|
@ -152,7 +152,7 @@ void mock_peer_connection::disconnect(error_code const& ec
|
|||
, std::static_pointer_cast<mock_peer_connection>(shared_from_this()));
|
||||
if (i != m_torrent.m_connections.end()) m_torrent.m_connections.erase(i);
|
||||
|
||||
m_tp = 0;
|
||||
m_tp = nullptr;
|
||||
m_disconnect_called = true;
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ TORRENT_TEST(multiple_ips_allowed2)
|
|||
// we only have one peer, we can't
|
||||
// connect another one
|
||||
tp = p.connect_one_peer(0, &st);
|
||||
TEST_CHECK(tp == NULL);
|
||||
TEST_CHECK(tp == nullptr);
|
||||
st.erased.clear();
|
||||
|
||||
torrent_peer* peer2 = p.add_peer(ep("10.0.0.2", 9020), 0, 0, &st);
|
||||
|
@ -309,7 +309,7 @@ TORRENT_TEST(multiple_ips_disallowed2)
|
|||
// we only have one peer, we can't
|
||||
// connect another one
|
||||
tp = p.connect_one_peer(0, &st);
|
||||
TEST_CHECK(tp == NULL);
|
||||
TEST_CHECK(tp == nullptr);
|
||||
st.erased.clear();
|
||||
|
||||
torrent_peer* peer2 = p.add_peer(ep("10.0.0.2", 9020), 0, 0, &st);
|
||||
|
@ -512,7 +512,7 @@ TORRENT_TEST(erase_peers)
|
|||
tcp::endpoint ep = rand_tcp_ep();
|
||||
torrent_peer* peer = add_peer(p, st, ep);
|
||||
TEST_CHECK(peer);
|
||||
if (peer == NULL || st.erased.size() > 0)
|
||||
if (peer == nullptr || st.erased.size() > 0)
|
||||
{
|
||||
std::fprintf(stderr, "unexpected rejection of peer: %s | %d in list. "
|
||||
"added peer %p, erased %d peers\n"
|
||||
|
@ -526,7 +526,7 @@ TORRENT_TEST(erase_peers)
|
|||
torrent_peer* peer = p.add_peer(rand_tcp_ep(), 0, 0, &st);
|
||||
// we either removed an existing peer, or rejected this one
|
||||
// either is valid behavior when the list is full
|
||||
TEST_CHECK(st.erased.size() == 1 || peer == NULL);
|
||||
TEST_CHECK(st.erased.size() == 1 || peer == nullptr);
|
||||
}
|
||||
|
||||
// test set_ip_filter
|
||||
|
@ -914,7 +914,7 @@ TORRENT_TEST(new_peer_size_limit)
|
|||
TEST_CHECK(peer5);
|
||||
TEST_EQUAL(p.num_peers(), 5);
|
||||
torrent_peer* peer6 = p.add_peer(ep("10.0.0.6", 8080), 0, 0, &st);
|
||||
TEST_CHECK(peer6 == NULL);
|
||||
TEST_CHECK(peer6 == nullptr);
|
||||
TEST_EQUAL(p.num_peers(), 5);
|
||||
|
||||
// one of the connection should have been removed
|
||||
|
|
|
@ -65,7 +65,7 @@ bitfield string2vec(char const* have_str)
|
|||
return have;
|
||||
}
|
||||
|
||||
ipv4_peer* tmp_peer = 0;
|
||||
ipv4_peer* tmp_peer = nullptr;
|
||||
|
||||
tcp::endpoint endp;
|
||||
ipv4_peer tmp0(endp, false, 0);
|
||||
|
@ -274,7 +274,7 @@ int test_pick(boost::shared_ptr<piece_picker> const& p
|
|||
, int options = piece_picker::rarest_first)
|
||||
{
|
||||
const std::vector<int> empty_vector;
|
||||
std::vector<piece_block> picked = pick_pieces(p, "*******", 1, 0, 0
|
||||
std::vector<piece_block> picked = pick_pieces(p, "*******", 1, 0, nullptr
|
||||
, options, empty_vector);
|
||||
if (picked.empty()) return -1;
|
||||
return picked[0].piece_index;
|
||||
|
@ -389,7 +389,7 @@ TORRENT_TEST(piece_picker)
|
|||
|
||||
p = setup_picker("1111111", " ", "7110000", "");
|
||||
p->mark_as_downloading(piece_block(0,0), &tmp1);
|
||||
p->mark_as_finished(piece_block(0,1), 0);
|
||||
p->mark_as_finished(piece_block(0,1), nullptr);
|
||||
p->piece_info(0, st);
|
||||
TEST_EQUAL(st.requested, 1);
|
||||
TEST_EQUAL(st.finished, 1);
|
||||
|
@ -397,7 +397,7 @@ TORRENT_TEST(piece_picker)
|
|||
p->piece_info(0, st);
|
||||
TEST_EQUAL(st.requested, 0);
|
||||
TEST_EQUAL(st.finished, 1);
|
||||
picked = pick_pieces(p, "*******", blocks_per_piece, 0, 0
|
||||
picked = pick_pieces(p, "*******", blocks_per_piece, 0, nullptr
|
||||
, options, empty_vector);
|
||||
TEST_CHECK(p->is_requested(piece_block(0, 0)) == false);
|
||||
TEST_CHECK(std::find(picked.begin(), picked.end(), piece_block(0,0)) != picked.end());
|
||||
|
@ -417,10 +417,10 @@ TORRENT_TEST(piece_picker)
|
|||
std::vector<torrent_peer*> d;
|
||||
p->get_downloaders(d, 0);
|
||||
TEST_EQUAL(d.size(), 4);
|
||||
TEST_CHECK(d[0] == NULL);
|
||||
TEST_CHECK(d[1] == NULL);
|
||||
TEST_CHECK(d[0] == nullptr);
|
||||
TEST_CHECK(d[1] == nullptr);
|
||||
TEST_CHECK(d[2] == &tmp2);
|
||||
TEST_CHECK(d[3] == NULL);
|
||||
TEST_CHECK(d[3] == nullptr);
|
||||
|
||||
p->mark_as_downloading(piece_block(0, 3), &tmp1);
|
||||
p->abort_download(piece_block(0, 3), &tmp1);
|
||||
|
@ -430,8 +430,8 @@ TORRENT_TEST(piece_picker)
|
|||
p->get_downloaders(d, 0);
|
||||
|
||||
TEST_EQUAL(d.size(), 4);
|
||||
TEST_CHECK(d[0] == NULL);
|
||||
TEST_CHECK(d[1] == NULL);
|
||||
TEST_CHECK(d[0] == nullptr);
|
||||
TEST_CHECK(d[1] == nullptr);
|
||||
TEST_CHECK(d[2] == &tmp2);
|
||||
TEST_CHECK(d[3] == &tmp2);
|
||||
|
||||
|
@ -440,10 +440,10 @@ TORRENT_TEST(piece_picker)
|
|||
p->get_downloaders(d, 1);
|
||||
|
||||
TEST_EQUAL(d.size(), 4);
|
||||
TEST_CHECK(d[0] == NULL);
|
||||
TEST_CHECK(d[1] == NULL);
|
||||
TEST_CHECK(d[2] == NULL);
|
||||
TEST_CHECK(d[3] == NULL);
|
||||
TEST_CHECK(d[0] == nullptr);
|
||||
TEST_CHECK(d[1] == nullptr);
|
||||
TEST_CHECK(d[2] == nullptr);
|
||||
TEST_CHECK(d[3] == nullptr);
|
||||
|
||||
// ========================================================
|
||||
|
||||
|
@ -576,7 +576,7 @@ TORRENT_TEST(piece_picker)
|
|||
p->we_dont_have(2);
|
||||
TEST_CHECK(!p->have_piece(1));
|
||||
TEST_CHECK(!p->have_piece(2));
|
||||
picked = pick_pieces(p, "*** ** ", 1, 0, 0, options, empty_vector);
|
||||
picked = pick_pieces(p, "*** ** ", 1, 0, nullptr, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) > 0);
|
||||
TEST_CHECK(picked.front().piece_index == 1);
|
||||
|
||||
|
@ -585,7 +585,7 @@ TORRENT_TEST(piece_picker)
|
|||
// make sure we can split m_seed when removing a refcount
|
||||
print_title("test dec_refcount split seed");
|
||||
p = setup_picker("0000000", " ", "0000000", "");
|
||||
p->inc_refcount_all(0);
|
||||
p->inc_refcount_all(nullptr);
|
||||
|
||||
std::vector<int> avail;
|
||||
p->get_availability(avail);
|
||||
|
@ -596,7 +596,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(avail[3] != 0);
|
||||
TEST_CHECK(avail[4] != 0);
|
||||
|
||||
p->dec_refcount(3, 0);
|
||||
p->dec_refcount(3, nullptr);
|
||||
|
||||
p->get_availability(avail);
|
||||
TEST_EQUAL(avail.size(), 7);
|
||||
|
@ -639,12 +639,12 @@ TORRENT_TEST(piece_picker)
|
|||
// make sure requested blocks aren't picked
|
||||
print_title("test don't pick requested blocks");
|
||||
p = setup_picker("1111111", " ", "", "");
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0, options, empty_vector);
|
||||
picked = pick_pieces(p, "*******", 1, 0, nullptr, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) > 0);
|
||||
piece_block first = picked.front();
|
||||
p->mark_as_downloading(picked.front(), &peer_struct);
|
||||
TEST_CHECK(p->num_peers(picked.front()) == 1);
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0, options, empty_vector);
|
||||
picked = pick_pieces(p, "*******", 1, 0, nullptr, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) > 0);
|
||||
TEST_CHECK(picked.front() != first);
|
||||
|
||||
|
@ -653,12 +653,12 @@ TORRENT_TEST(piece_picker)
|
|||
// make sure downloading pieces have higher priority
|
||||
print_title("test downloading piece priority");
|
||||
p = setup_picker("1111111", " ", "", "");
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0, options, empty_vector);
|
||||
picked = pick_pieces(p, "*******", 1, 0, nullptr, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) > 0);
|
||||
first = picked.front();
|
||||
p->mark_as_downloading(picked.front(), &peer_struct);
|
||||
TEST_CHECK(p->num_peers(picked.front()) == 1);
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0, options, empty_vector);
|
||||
picked = pick_pieces(p, "*******", 1, 0, nullptr, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) > 0);
|
||||
TEST_CHECK(picked.front() != first);
|
||||
TEST_CHECK(picked.front().piece_index == first.piece_index);
|
||||
|
@ -679,7 +679,7 @@ TORRENT_TEST(piece_picker)
|
|||
// 2. Piece 2 is the best pick in this case.
|
||||
print_title("test partial piece order (rarest first)");
|
||||
p = setup_picker("1112111", " ", "", "013700f");
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0
|
||||
picked = pick_pieces(p, "*******", 1, 0, nullptr
|
||||
, options | piece_picker::prioritize_partials, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) > 0);
|
||||
TEST_CHECK(picked.front() == piece_block(2, 2)
|
||||
|
@ -691,7 +691,7 @@ TORRENT_TEST(piece_picker)
|
|||
|
||||
print_title("test partial piece order (most complete)");
|
||||
p = setup_picker("1111111", " ", "", "013700f");
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0
|
||||
picked = pick_pieces(p, "*******", 1, 0, nullptr
|
||||
, options | piece_picker::prioritize_partials, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) > 0);
|
||||
TEST_CHECK(picked.front() == piece_block(3, 3));
|
||||
|
@ -701,7 +701,7 @@ TORRENT_TEST(piece_picker)
|
|||
|
||||
print_title("test partial piece order (sequential)");
|
||||
p = setup_picker("1111111", " ", "", "013700f");
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0
|
||||
picked = pick_pieces(p, "*******", 1, 0, nullptr
|
||||
, piece_picker::sequential | piece_picker::prioritize_partials, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) > 0);
|
||||
TEST_CHECK(picked.front() == piece_block(1, 1)
|
||||
|
@ -713,7 +713,7 @@ TORRENT_TEST(piece_picker)
|
|||
// make sure the random piece picker can still pick partial pieces
|
||||
print_title("test random picking (downloading piece)");
|
||||
p = setup_picker("1111111", " ", "", "013700f");
|
||||
picked = pick_pieces(p, " *** *", 1, 0, 0
|
||||
picked = pick_pieces(p, " *** *", 1, 0, nullptr
|
||||
, 0, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) > 0);
|
||||
TEST_CHECK(picked.front() == piece_block(1, 1)
|
||||
|
@ -724,7 +724,7 @@ TORRENT_TEST(piece_picker)
|
|||
// even when prefer_contiguous_blocks is set
|
||||
print_title("test random picking (downloading piece, prefer contiguous)");
|
||||
p = setup_picker("1111111", " ", "", "013700f");
|
||||
picked = pick_pieces(p, " *** *", 1, 4, 0
|
||||
picked = pick_pieces(p, " *** *", 1, 4, nullptr
|
||||
, 0, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) > 0);
|
||||
TEST_CHECK(picked.front() == piece_block(1, 1)
|
||||
|
@ -737,7 +737,7 @@ TORRENT_TEST(piece_picker)
|
|||
// test sequential download
|
||||
print_title("test sequential download");
|
||||
p = setup_picker("7654321", " ", "", "");
|
||||
picked = pick_pieces(p, "*******", 7 * blocks_per_piece, 0, 0
|
||||
picked = pick_pieces(p, "*******", 7 * blocks_per_piece, 0, nullptr
|
||||
, piece_picker::sequential, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) == 7 * blocks_per_piece);
|
||||
for (int i = 0; i < int(picked.size()); ++i)
|
||||
|
@ -748,7 +748,7 @@ TORRENT_TEST(piece_picker)
|
|||
// test reverse sequential download
|
||||
print_title("test reverse sequential download");
|
||||
p = setup_picker("7654321", " ", "", "");
|
||||
picked = pick_pieces(p, "*******", 7 * blocks_per_piece, 0, 0
|
||||
picked = pick_pieces(p, "*******", 7 * blocks_per_piece, 0, nullptr
|
||||
, piece_picker::sequential | piece_picker::reverse, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) == 7 * blocks_per_piece);
|
||||
for (int i = 0; i < int(picked.size()); ++i)
|
||||
|
@ -759,7 +759,7 @@ TORRENT_TEST(piece_picker)
|
|||
// test priority sequential download
|
||||
print_title("test priority sequential download");
|
||||
p = setup_picker("7654321", " ", "1117071", "");
|
||||
picked = pick_pieces(p, "*******", 7 * blocks_per_piece, 0, 0
|
||||
picked = pick_pieces(p, "*******", 7 * blocks_per_piece, 0, nullptr
|
||||
, piece_picker::sequential, empty_vector);
|
||||
|
||||
// the piece with priority 0 was not picked, everything else should
|
||||
|
@ -972,7 +972,7 @@ TORRENT_TEST(piece_picker)
|
|||
p->set_piece_priority(0, 0);
|
||||
TEST_CHECK(p->num_filtered() == 1);
|
||||
TEST_CHECK(p->num_have_filtered() == 0);
|
||||
p->mark_as_finished(piece_block(0,0), 0);
|
||||
p->mark_as_finished(piece_block(0,0), nullptr);
|
||||
p->we_have(0);
|
||||
TEST_CHECK(p->num_filtered() == 0);
|
||||
TEST_CHECK(p->num_have_filtered() == 1);
|
||||
|
@ -980,7 +980,7 @@ TORRENT_TEST(piece_picker)
|
|||
p->we_dont_have(0);
|
||||
p->set_piece_priority(0, 7);
|
||||
|
||||
picked = pick_pieces(p, "*******", 7 * blocks_per_piece, 0, 0
|
||||
picked = pick_pieces(p, "*******", 7 * blocks_per_piece, 0, nullptr
|
||||
, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) == 7 * blocks_per_piece);
|
||||
|
||||
|
@ -1010,37 +1010,37 @@ TORRENT_TEST(piece_picker)
|
|||
// test restore_piece
|
||||
print_title("test restore piece");
|
||||
p = setup_picker("1234567", " ", "", "");
|
||||
p->mark_as_finished(piece_block(0,0), 0);
|
||||
p->mark_as_finished(piece_block(0,1), 0);
|
||||
p->mark_as_finished(piece_block(0,2), 0);
|
||||
p->mark_as_finished(piece_block(0,3), 0);
|
||||
p->mark_as_finished(piece_block(0,0), nullptr);
|
||||
p->mark_as_finished(piece_block(0,1), nullptr);
|
||||
p->mark_as_finished(piece_block(0,2), nullptr);
|
||||
p->mark_as_finished(piece_block(0,3), nullptr);
|
||||
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0, options, empty_vector);
|
||||
picked = pick_pieces(p, "*******", 1, 0, nullptr, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) >= 1);
|
||||
TEST_CHECK(picked.front().piece_index == 1);
|
||||
|
||||
p->restore_piece(0);
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0, options, empty_vector);
|
||||
picked = pick_pieces(p, "*******", 1, 0, nullptr, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) >= 1);
|
||||
TEST_CHECK(picked.front().piece_index == 0);
|
||||
|
||||
p->mark_as_finished(piece_block(0,0), 0);
|
||||
p->mark_as_finished(piece_block(0,1), 0);
|
||||
p->mark_as_finished(piece_block(0,2), 0);
|
||||
p->mark_as_finished(piece_block(0,3), 0);
|
||||
p->mark_as_finished(piece_block(0,0), nullptr);
|
||||
p->mark_as_finished(piece_block(0,1), nullptr);
|
||||
p->mark_as_finished(piece_block(0,2), nullptr);
|
||||
p->mark_as_finished(piece_block(0,3), nullptr);
|
||||
p->set_piece_priority(0, 0);
|
||||
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0, options, empty_vector);
|
||||
picked = pick_pieces(p, "*******", 1, 0, nullptr, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) >= 1);
|
||||
TEST_CHECK(picked.front().piece_index == 1);
|
||||
|
||||
p->restore_piece(0);
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0, options, empty_vector);
|
||||
picked = pick_pieces(p, "*******", 1, 0, nullptr, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) >= 1);
|
||||
TEST_CHECK(picked.front().piece_index == 1);
|
||||
|
||||
p->set_piece_priority(0, 7);
|
||||
picked = pick_pieces(p, "*******", 1, 0, 0, options, empty_vector);
|
||||
picked = pick_pieces(p, "*******", 1, 0, nullptr, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) >= 1);
|
||||
TEST_CHECK(picked.front().piece_index == 0);
|
||||
|
||||
|
@ -1073,7 +1073,7 @@ TORRENT_TEST(piece_picker)
|
|||
p->mark_as_downloading(piece_block(1,2), &tmp1);
|
||||
|
||||
picked.clear();
|
||||
p->pick_pieces(string2vec("*******"), picked, 7 * blocks_per_piece, 0, 0
|
||||
p->pick_pieces(string2vec("*******"), picked, 7 * blocks_per_piece, 0, nullptr
|
||||
, piece_picker::prioritize_partials, empty_vector, 20
|
||||
, pc);
|
||||
TEST_CHECK(verify_pick(p, picked, true));
|
||||
|
@ -1082,7 +1082,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_EQUAL(picked.size(), 7 * blocks_per_piece - 2);
|
||||
|
||||
picked.clear();
|
||||
p->pick_pieces(string2vec("*******"), picked, 7 * blocks_per_piece, 0, 0
|
||||
p->pick_pieces(string2vec("*******"), picked, 7 * blocks_per_piece, 0, nullptr
|
||||
, piece_picker::prioritize_partials
|
||||
| piece_picker::rarest_first, empty_vector, 20
|
||||
, pc);
|
||||
|
@ -1092,7 +1092,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_EQUAL(picked.size(), 7 * blocks_per_piece - 2);
|
||||
|
||||
picked.clear();
|
||||
p->pick_pieces(string2vec("*******"), picked, 7 * blocks_per_piece, 0, 0
|
||||
p->pick_pieces(string2vec("*******"), picked, 7 * blocks_per_piece, 0, nullptr
|
||||
, piece_picker::rarest_first, empty_vector, 20
|
||||
, pc);
|
||||
TEST_CHECK(verify_pick(p, picked, true));
|
||||
|
@ -1102,7 +1102,7 @@ TORRENT_TEST(piece_picker)
|
|||
|
||||
// make sure we still pick from a partial piece even when prefering whole pieces
|
||||
picked.clear();
|
||||
p->pick_pieces(string2vec(" * "), picked, 1, blocks_per_piece, 0
|
||||
p->pick_pieces(string2vec(" * "), picked, 1, blocks_per_piece, nullptr
|
||||
, piece_picker::rarest_first
|
||||
| piece_picker::align_expanded_pieces, empty_vector, 20
|
||||
, pc);
|
||||
|
@ -1115,7 +1115,7 @@ TORRENT_TEST(piece_picker)
|
|||
// don't pick locked pieces
|
||||
picked.clear();
|
||||
p->lock_piece(1);
|
||||
p->pick_pieces(string2vec(" ** "), picked, 7, 0, 0
|
||||
p->pick_pieces(string2vec(" ** "), picked, 7, 0, nullptr
|
||||
, piece_picker::rarest_first, empty_vector, 20
|
||||
, pc);
|
||||
TEST_CHECK(verify_pick(p, picked, true));
|
||||
|
@ -1134,7 +1134,7 @@ TORRENT_TEST(piece_picker)
|
|||
p->mark_as_downloading(piece_block(1,3), &tmp1);
|
||||
|
||||
picked.clear();
|
||||
p->pick_pieces(string2vec(" ** "), picked, 2, 0, 0
|
||||
p->pick_pieces(string2vec(" ** "), picked, 2, 0, nullptr
|
||||
, piece_picker::rarest_first, empty_vector, 20
|
||||
, pc);
|
||||
TEST_CHECK(verify_pick(p, picked, true));
|
||||
|
@ -1143,7 +1143,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_EQUAL(picked.size(), 1);
|
||||
|
||||
picked.clear();
|
||||
p->pick_pieces(string2vec(" ** "), picked, 2 * blocks_per_piece, 0, 0
|
||||
p->pick_pieces(string2vec(" ** "), picked, 2 * blocks_per_piece, 0, nullptr
|
||||
, piece_picker::prioritize_partials, empty_vector, 0
|
||||
, pc);
|
||||
TEST_CHECK(verify_pick(p, picked, true));
|
||||
|
@ -1152,7 +1152,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_EQUAL(picked.size(), 1);
|
||||
|
||||
picked.clear();
|
||||
p->pick_pieces(string2vec(" ** "), picked, 2 * blocks_per_piece, 0, 0
|
||||
p->pick_pieces(string2vec(" ** "), picked, 2 * blocks_per_piece, 0, nullptr
|
||||
, piece_picker::prioritize_partials, empty_vector, 20
|
||||
, pc);
|
||||
TEST_CHECK(verify_pick(p, picked, true));
|
||||
|
@ -1173,11 +1173,11 @@ TORRENT_TEST(piece_picker)
|
|||
p->mark_as_downloading(piece_block(3, 1), &tmp3);
|
||||
|
||||
std::vector<torrent_peer*> dls;
|
||||
torrent_peer* expected_dls1[] = {&tmp1, &tmp2, &tmp3, 0};
|
||||
torrent_peer* expected_dls2[] = {0, &tmp1, 0, 0};
|
||||
torrent_peer* expected_dls3[] = {0, &tmp2, 0, 0};
|
||||
torrent_peer* expected_dls4[] = {0, &tmp3, 0, 0};
|
||||
torrent_peer* expected_dls5[] = {&tmp1, 0, &tmp3, 0};
|
||||
torrent_peer* expected_dls1[] = {&tmp1, &tmp2, &tmp3, nullptr};
|
||||
torrent_peer* expected_dls2[] = {nullptr, &tmp1, nullptr, nullptr};
|
||||
torrent_peer* expected_dls3[] = {nullptr, &tmp2, nullptr, nullptr};
|
||||
torrent_peer* expected_dls4[] = {nullptr, &tmp3, nullptr, nullptr};
|
||||
torrent_peer* expected_dls5[] = {&tmp1, nullptr, &tmp3, nullptr};
|
||||
p->get_downloaders(dls, 0);
|
||||
TEST_CHECK(std::equal(dls.begin(), dls.end(), expected_dls1));
|
||||
p->get_downloaders(dls, 1);
|
||||
|
@ -1275,7 +1275,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(p->get_downloader(piece_block(4, 0)) == tmp_peer);
|
||||
TEST_CHECK(p->get_downloader(piece_block(4, 1)) == tmp_peer);
|
||||
TEST_CHECK(p->get_downloader(piece_block(4, 2)) == tmp_peer);
|
||||
TEST_CHECK(p->get_downloader(piece_block(4, 3)) == 0);
|
||||
TEST_CHECK(p->get_downloader(piece_block(4, 3)) == nullptr);
|
||||
p->mark_as_downloading(piece_block(4, 3), &peer_struct);
|
||||
TEST_CHECK(p->get_downloader(piece_block(4, 3)) == &peer_struct);
|
||||
p->piece_info(4, st);
|
||||
|
@ -1302,7 +1302,7 @@ TORRENT_TEST(piece_picker)
|
|||
TEST_CHECK(st.requested == 0);
|
||||
TEST_CHECK(st.writing == 0);
|
||||
TEST_CHECK(st.finished == 4);
|
||||
TEST_CHECK(p->get_downloader(piece_block(4, 3)) == 0);
|
||||
TEST_CHECK(p->get_downloader(piece_block(4, 3)) == nullptr);
|
||||
TEST_CHECK(p->unverified_blocks() == 2);
|
||||
|
||||
// ========================================================
|
||||
|
@ -1311,7 +1311,7 @@ TORRENT_TEST(piece_picker)
|
|||
print_title("test prefer contiguous blocks");
|
||||
p = setup_picker("1111111", " ", "", "");
|
||||
picked = pick_pieces(p, "*******", 1, 3 * blocks_per_piece
|
||||
, 0, options, empty_vector);
|
||||
, nullptr, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) >= 3 * blocks_per_piece);
|
||||
piece_block b = picked.front();
|
||||
for (int i = 1; i < int(picked.size()); ++i)
|
||||
|
@ -1322,7 +1322,7 @@ TORRENT_TEST(piece_picker)
|
|||
}
|
||||
|
||||
picked = pick_pieces(p, "*******", 1, 3 * blocks_per_piece
|
||||
, 0, options, empty_vector);
|
||||
, nullptr, options, empty_vector);
|
||||
TEST_CHECK(int(picked.size()) >= 3 * blocks_per_piece);
|
||||
b = picked.front();
|
||||
for (int i = 1; i < int(picked.size()); ++i)
|
||||
|
@ -1337,14 +1337,14 @@ TORRENT_TEST(piece_picker)
|
|||
p = setup_picker("1111111", " ", "", "");
|
||||
p->mark_as_downloading(piece_block(2,2), &tmp1);
|
||||
picked = pick_pieces(p, "*******", 7 * blocks_per_piece - 1, blocks_per_piece
|
||||
, 0, options, empty_vector);
|
||||
, nullptr, options, empty_vector);
|
||||
TEST_CHECK(picked.size() == 7 * blocks_per_piece - 1);
|
||||
TEST_CHECK(std::find(picked.begin(), picked.end(), piece_block(2,2)) == picked.end());
|
||||
|
||||
// test aligned whole pieces
|
||||
print_title("test prefer aligned whole pieces");
|
||||
p = setup_picker("2222221222222222", " ", "", "");
|
||||
picked = pick_pieces(p, "****************", 1, 4 * blocks_per_piece, 0
|
||||
picked = pick_pieces(p, "****************", 1, 4 * blocks_per_piece, nullptr
|
||||
, options | piece_picker::align_expanded_pieces, empty_vector);
|
||||
|
||||
// the piece picker should pick piece 5, and then align it to even 4 pieces
|
||||
|
@ -1368,8 +1368,8 @@ TORRENT_TEST(piece_picker)
|
|||
// test parole mode
|
||||
print_title("test parole mode");
|
||||
p = setup_picker("3333133", " ", "", "");
|
||||
p->mark_as_finished(piece_block(0, 0), 0);
|
||||
picked = pick_pieces(p, "*******", 1, blocks_per_piece, 0
|
||||
p->mark_as_finished(piece_block(0, 0), nullptr);
|
||||
picked = pick_pieces(p, "*******", 1, blocks_per_piece, nullptr
|
||||
|
||||
, options | piece_picker::on_parole | piece_picker::prioritize_partials, empty_vector);
|
||||
TEST_EQUAL(int(picked.size()), blocks_per_piece - 1);
|
||||
|
@ -1394,7 +1394,7 @@ TORRENT_TEST(piece_picker)
|
|||
const std::vector<int> suggested_pieces(v, v + 2);
|
||||
|
||||
picked = pick_pieces(p, "****************", 1, blocks_per_piece
|
||||
, 0, options, suggested_pieces);
|
||||
, nullptr, options, suggested_pieces);
|
||||
TEST_CHECK(int(picked.size()) >= blocks_per_piece);
|
||||
for (int i = 1; i < int(picked.size()); ++i)
|
||||
TEST_CHECK(picked[i] == piece_block(1, i));
|
||||
|
@ -1404,14 +1404,14 @@ TORRENT_TEST(piece_picker)
|
|||
p->set_piece_priority(3, 0);
|
||||
|
||||
picked = pick_pieces(p, "****************", 1, blocks_per_piece
|
||||
, 0, options, suggested_pieces);
|
||||
, nullptr, options, suggested_pieces);
|
||||
TEST_CHECK(int(picked.size()) >= blocks_per_piece);
|
||||
for (int i = 1; i < int(picked.size()); ++i)
|
||||
TEST_CHECK(picked[i] == piece_block(5, i));
|
||||
|
||||
p = setup_picker("1111222233334444", "**** ", "", "");
|
||||
picked = pick_pieces(p, "****************", 1, blocks_per_piece
|
||||
, 0, options, suggested_pieces);
|
||||
, nullptr, options, suggested_pieces);
|
||||
TEST_CHECK(int(picked.size()) >= blocks_per_piece);
|
||||
for (int i = 1; i < int(picked.size()); ++i)
|
||||
TEST_CHECK(picked[i] == piece_block(5, i));
|
||||
|
@ -1423,13 +1423,13 @@ TORRENT_TEST(piece_picker)
|
|||
// we have less than half of the pieces
|
||||
p = setup_picker("2122222211221222", " ", "", "");
|
||||
// make sure it's not dirty
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, 0);
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, nullptr);
|
||||
print_availability(p);
|
||||
p->dec_refcount(string2vec("** ** ** * "), &tmp0);
|
||||
print_availability(p);
|
||||
TEST_CHECK(verify_availability(p, "1022112200220222"));
|
||||
// make sure it's not dirty
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, 0);
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, nullptr);
|
||||
p->inc_refcount(string2vec(" ** ** * * "), &tmp8);
|
||||
print_availability(p);
|
||||
TEST_CHECK(verify_availability(p, "1132123201220322"));
|
||||
|
@ -1441,22 +1441,22 @@ TORRENT_TEST(piece_picker)
|
|||
p = setup_picker("0000000000000000", " ", "", "");
|
||||
|
||||
// make sure it's not dirty
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, 0);
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, nullptr);
|
||||
|
||||
p->inc_refcount_all(&tmp0);
|
||||
print_availability(p);
|
||||
TEST_CHECK(verify_availability(p, "1111111111111111"));
|
||||
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, 0);
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, nullptr);
|
||||
p->dec_refcount(string2vec(" **** ** "), &tmp0);
|
||||
print_availability(p);
|
||||
TEST_CHECK(verify_availability(p, "1100001100111111"));
|
||||
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, 0);
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, nullptr);
|
||||
p->inc_refcount(string2vec(" **** ** "), &tmp0);
|
||||
TEST_CHECK(verify_availability(p, "1111111111111111"));
|
||||
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, 0);
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, nullptr);
|
||||
p->dec_refcount_all(&tmp0);
|
||||
TEST_CHECK(verify_availability(p, "0000000000000000"));
|
||||
|
||||
|
@ -1464,7 +1464,7 @@ TORRENT_TEST(piece_picker)
|
|||
print_availability(p);
|
||||
TEST_CHECK(verify_availability(p, "1111111111111111"));
|
||||
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, 0);
|
||||
pick_pieces(p, "****************", 1, blocks_per_piece, nullptr);
|
||||
p->dec_refcount(3, &tmp1);
|
||||
print_availability(p);
|
||||
TEST_CHECK(verify_availability(p, "1110111111111111"));
|
||||
|
@ -1715,19 +1715,19 @@ TORRENT_TEST(piece_picker)
|
|||
// also make sure restore_piece() unlocks it and makes
|
||||
// it available for picking again.
|
||||
|
||||
picked = pick_pieces(p, " * ", 1, blocks_per_piece, 0);
|
||||
picked = pick_pieces(p, " * ", 1, blocks_per_piece, nullptr);
|
||||
TEST_EQUAL(picked.size(), 0);
|
||||
|
||||
p->restore_piece(1);
|
||||
|
||||
picked = pick_pieces(p, " * ", 1, blocks_per_piece, 0);
|
||||
picked = pick_pieces(p, " * ", 1, blocks_per_piece, nullptr);
|
||||
TEST_EQUAL(picked.size(), blocks_per_piece);
|
||||
|
||||
// locking pieces only works on partial pieces
|
||||
p->mark_as_writing(piece_block(1, 0), &tmp1);
|
||||
p->lock_piece(1);
|
||||
|
||||
picked = pick_pieces(p, " * ", 1, blocks_per_piece, 0);
|
||||
picked = pick_pieces(p, " * ", 1, blocks_per_piece, nullptr);
|
||||
TEST_EQUAL(picked.size(), 0);
|
||||
|
||||
// ========================================================
|
||||
|
|
|
@ -132,8 +132,8 @@ void test_transfer(settings_pack const& sett, bool test_deprecated = false)
|
|||
peer_disconnects = 0;
|
||||
|
||||
// test using piece sizes smaller than 16kB
|
||||
std::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, 0
|
||||
, true, false, true, "_priority", 8 * 1024, &t, false, 0);
|
||||
std::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, nullptr
|
||||
, true, false, true, "_priority", 8 * 1024, &t, false, nullptr);
|
||||
|
||||
int num_pieces = tor2.torrent_file()->num_pieces();
|
||||
std::vector<int> priorities(num_pieces, 1);
|
||||
|
|
|
@ -62,7 +62,7 @@ std::vector<std::string> rejected_trackers;
|
|||
bool alert_predicate(libtorrent::alert const* a)
|
||||
{
|
||||
anonymous_mode_alert const* am = alert_cast<anonymous_mode_alert>(a);
|
||||
if (am == NULL) return false;
|
||||
if (am == nullptr) return false;
|
||||
|
||||
if (am->kind == anonymous_mode_alert::tracker_not_anonymous)
|
||||
rejected_trackers.push_back(am->str);
|
||||
|
|
|
@ -145,7 +145,7 @@ void test_remap_files_gather(storage_mode_t storage_mode = storage_mode_sparse)
|
|||
peer_disconnects = 0;
|
||||
|
||||
// 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, "_remap", 8 * 1024, &t, false, ¶ms
|
||||
, true, false, &t2);
|
||||
|
||||
|
@ -202,7 +202,7 @@ void test_remap_files_gather(storage_mode_t storage_mode = storage_mode_sparse)
|
|||
|
||||
if (i % 10 == 0)
|
||||
{
|
||||
print_ses_rate(i / 10.f, NULL, &st2);
|
||||
print_ses_rate(i / 10.f, nullptr, &st2);
|
||||
}
|
||||
|
||||
if (st2.state != torrent_status::checking_files)
|
||||
|
@ -289,7 +289,7 @@ void test_remap_files_scatter(storage_mode_t storage_mode = storage_mode_sparse)
|
|||
peer_disconnects = 0;
|
||||
|
||||
// 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, "_remap2", 8 * 1024, &t, false, ¶ms
|
||||
, true, false, &t2);
|
||||
|
||||
|
@ -346,7 +346,7 @@ void test_remap_files_scatter(storage_mode_t storage_mode = storage_mode_sparse)
|
|||
|
||||
if (i % 10 == 0)
|
||||
{
|
||||
print_ses_rate(i / 10.f, NULL, &st2);
|
||||
print_ses_rate(i / 10.f, nullptr, &st2);
|
||||
}
|
||||
|
||||
if (st2.state != torrent_status::checking_files)
|
||||
|
@ -453,7 +453,7 @@ void test_remap_files_prio(storage_mode_t storage_mode = storage_mode_sparse)
|
|||
peer_disconnects = 0;
|
||||
|
||||
// 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, "_remap3", 8 * 1024, &t, false, ¶ms
|
||||
, true, false, &t2);
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ TORRENT_TEST(resume_save_load_deprecated)
|
|||
, "resume_save_load"));
|
||||
|
||||
TEST_CHECK(a);
|
||||
if (a == NULL) return;
|
||||
if (a == nullptr) return;
|
||||
|
||||
TEST_CHECK(a->resume_data);
|
||||
|
||||
|
@ -353,7 +353,7 @@ TORRENT_TEST(resume_save_load_resume_deprecated)
|
|||
, "resume_save_load"));
|
||||
|
||||
TEST_CHECK(a);
|
||||
if (a == NULL) return;
|
||||
if (a == nullptr) return;
|
||||
|
||||
TEST_CHECK(a->resume_data);
|
||||
|
||||
|
@ -912,7 +912,7 @@ TORRENT_TEST(resume_save_load)
|
|||
, "resume_save_load"));
|
||||
|
||||
TEST_CHECK(a);
|
||||
if (a == NULL) return;
|
||||
if (a == nullptr) return;
|
||||
|
||||
TEST_CHECK(a->resume_data);
|
||||
|
||||
|
@ -939,7 +939,7 @@ TORRENT_TEST(resume_save_load_resume)
|
|||
, "resume_save_load"));
|
||||
|
||||
TEST_CHECK(a);
|
||||
if (a == NULL) return;
|
||||
if (a == nullptr) return;
|
||||
|
||||
TEST_CHECK(a->resume_data);
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ TORRENT_TEST(session)
|
|||
{
|
||||
a = wait_for_alert(ses, performance_alert::alert_type, "ses1");
|
||||
|
||||
if (a == NULL) break;
|
||||
if (a == nullptr) break;
|
||||
TEST_EQUAL(a->type(), performance_alert::alert_type);
|
||||
|
||||
if (alert_cast<performance_alert>(a)->warning_code
|
||||
|
|
|
@ -45,8 +45,8 @@ static sha1_hash to_hash(char const* s)
|
|||
|
||||
TORRENT_TEST(sha1_hash)
|
||||
{
|
||||
sha1_hash h1(0);
|
||||
sha1_hash h2(0);
|
||||
sha1_hash h1(nullptr);
|
||||
sha1_hash h2(nullptr);
|
||||
TEST_CHECK(h1 == h2);
|
||||
TEST_CHECK(!(h1 != h2));
|
||||
TEST_CHECK(!(h1 < h2));
|
||||
|
|
|
@ -430,8 +430,8 @@ void test_check_files(std::string const& test_path
|
|||
|
||||
libtorrent::create_torrent t(fs, piece_size, -1, 0);
|
||||
t.set_hash(0, hasher(piece0.get(), piece_size).final());
|
||||
t.set_hash(1, sha1_hash(0));
|
||||
t.set_hash(2, sha1_hash(0));
|
||||
t.set_hash(1, sha1_hash(nullptr));
|
||||
t.set_hash(2, sha1_hash(nullptr));
|
||||
t.set_hash(3, hasher(piece2.get(), piece_size).final());
|
||||
|
||||
create_directory(combine_path(test_path, "temp_storage"), ec);
|
||||
|
@ -455,7 +455,7 @@ void test_check_files(std::string const& test_path
|
|||
file_pool fp;
|
||||
boost::asio::io_service ios;
|
||||
counters cnt;
|
||||
disk_io_thread io(ios, cnt, NULL);
|
||||
disk_io_thread io(ios, cnt, nullptr);
|
||||
io.set_num_threads(1);
|
||||
disk_buffer_pool dp(16 * 1024, ios, std::bind(&nop));
|
||||
storage_params p;
|
||||
|
@ -712,7 +712,7 @@ void test_fastresume(bool const test_deprecated)
|
|||
alert const* a = wait_for_alert(ses, fastresume_rejected_alert::alert_type
|
||||
, "ses");
|
||||
// we expect the fast resume to be rejected because the files were removed
|
||||
TEST_CHECK(alert_cast<fastresume_rejected_alert>(a) != 0);
|
||||
TEST_CHECK(alert_cast<fastresume_rejected_alert>(a) != nullptr);
|
||||
}
|
||||
remove_all(combine_path(test_path, "tmp1"), ec);
|
||||
if (ec && ec != boost::system::errc::no_such_file_or_directory)
|
||||
|
@ -905,7 +905,7 @@ void free_iov(file::iovec_t* iov, int num_bufs)
|
|||
{
|
||||
free(iov[i].iov_base);
|
||||
iov[i].iov_len = 0;
|
||||
iov[i].iov_base = NULL;
|
||||
iov[i].iov_base = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ TORRENT_TEST(hex)
|
|||
|
||||
for (int i = 1; i < 255; ++i)
|
||||
{
|
||||
bool hex = strchr(hex_chars, i) != NULL;
|
||||
bool hex = strchr(hex_chars, i) != nullptr;
|
||||
char c = i;
|
||||
TEST_EQUAL(aux::is_hex(&c, 1), hex);
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ TORRENT_TEST(tokenize)
|
|||
TEST_EQUAL(ptr, std::string("f"));
|
||||
|
||||
ptr = string_tokenize(next, ' ', &next);
|
||||
TEST_EQUAL(ptr, static_cast<char*>(0));
|
||||
TEST_EQUAL(ptr, static_cast<char*>(nullptr));
|
||||
|
||||
TEST_EQUAL(std::string("foobar"), convert_from_native(convert_to_native("foobar")));
|
||||
TEST_EQUAL(std::string("foobar")
|
||||
|
|
|
@ -728,7 +728,7 @@ TORRENT_TEST(parse_torrents)
|
|||
, (flags & file_storage::flag_symlink)?'l':'-'
|
||||
, first, last
|
||||
, std::uint32_t(fs.mtime(i))
|
||||
, fs.hash(i) != sha1_hash(0) ? aux::to_hex(fs.hash(i).to_string()).c_str() : ""
|
||||
, fs.hash(i) != sha1_hash(nullptr) ? aux::to_hex(fs.hash(i).to_string()).c_str() : ""
|
||||
, fs.file_path(i).c_str()
|
||||
, flags & file_storage::flag_symlink ? "-> ": ""
|
||||
, flags & file_storage::flag_symlink ? fs.symlink(i).c_str() : "");
|
||||
|
@ -879,8 +879,8 @@ TORRENT_TEST(copy)
|
|||
|
||||
sha1_hash file_hashes[] =
|
||||
{
|
||||
sha1_hash(0),
|
||||
sha1_hash(0),
|
||||
sha1_hash(nullptr),
|
||||
sha1_hash(nullptr),
|
||||
sha1_hash("abababababababababab")
|
||||
};
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ peer_entry extract_peer(char const* peer_field, error_code expected_ec, bool exp
|
|||
peer_entry result;
|
||||
bdecode_node n;
|
||||
bdecode(peer_field, peer_field + strlen(peer_field)
|
||||
, n, ec, NULL, 1000, 1000);
|
||||
, n, ec, nullptr, 1000, 1000);
|
||||
TEST_CHECK(!ec);
|
||||
bool ret = extract_peer_info(n, result, ec);
|
||||
TEST_EQUAL(expected_ret, ret);
|
||||
|
@ -500,11 +500,11 @@ void test_proxy(bool proxy_trackers)
|
|||
const alert* a = wait_for_alert(*s, tracker_reply_alert::alert_type, "s");
|
||||
if (proxy_trackers)
|
||||
{
|
||||
TEST_CHECK(a == NULL);
|
||||
TEST_CHECK(a == nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
TEST_CHECK(a != NULL);
|
||||
TEST_CHECK(a != nullptr);
|
||||
}
|
||||
|
||||
std::fprintf(stderr, "destructing session\n");
|
||||
|
|
|
@ -247,7 +247,7 @@ void test_transfer(int proxy_type, settings_pack const& sett
|
|||
peer_disconnects = 0;
|
||||
|
||||
// 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, "_transfer", 8 * 1024, &t, false, test_disk_full?&addp:¶ms);
|
||||
|
||||
int num_pieces = tor2.torrent_file()->num_pieces();
|
||||
|
|
|
@ -45,7 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
namespace lt = libtorrent;
|
||||
using namespace libtorrent;
|
||||
|
||||
broadcast_socket* sock = 0;
|
||||
broadcast_socket* sock = nullptr;
|
||||
int g_port = 0;
|
||||
|
||||
char const* soap_add_response[] = {
|
||||
|
@ -141,7 +141,7 @@ void run_upnp_test(char const* root_filename, char const* router_model, char con
|
|||
buf.push_back(0);
|
||||
|
||||
FILE* xml_file = fopen("upnp.xml", "w+");
|
||||
if (xml_file == NULL)
|
||||
if (xml_file == nullptr)
|
||||
{
|
||||
std::fprintf(stderr, "failed to open file 'upnp.xml': %s\n", strerror(errno));
|
||||
TEST_CHECK(false);
|
||||
|
|
|
@ -102,7 +102,7 @@ void test_transfer()
|
|||
// atp.storage = &disabled_storage_constructor;
|
||||
|
||||
// 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, "_utp", 0, &t, false, &atp);
|
||||
|
||||
const int timeout = 8;
|
||||
|
|
|
@ -95,7 +95,7 @@ TORRENT_TEST(web_seed_redirect)
|
|||
|
||||
// disable keep-alive because otherwise the test will choke on seeing
|
||||
// the disconnect (from the redirect)
|
||||
test_transfer(ses, torrent_file, 0, 0, "http", true, false, false, false);
|
||||
test_transfer(ses, torrent_file, 0, nullptr, "http", true, false, false, false);
|
||||
}
|
||||
|
||||
stop_web_server();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue