diff --git a/include/libtorrent/sha1_hash.hpp b/include/libtorrent/sha1_hash.hpp index e880d8915..c24bda0fb 100644 --- a/include/libtorrent/sha1_hash.hpp +++ b/include/libtorrent/sha1_hash.hpp @@ -83,7 +83,7 @@ namespace libtorrent static sha1_hash min() { sha1_hash ret; - std::memset(ret.m_number, 0, size()); + // all bits are already 0 return ret; } @@ -92,7 +92,7 @@ namespace libtorrent // are ignored, ``s`` is treated like a raw memory buffer. explicit sha1_hash(char const* s) { - if (s == 0) clear(); + if (s == nullptr) clear(); else std::memcpy(m_number, s, size()); } #ifndef TORRENT_NO_DEPRECATE diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index ee07a9f95..cc46c4014 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -475,12 +475,9 @@ namespace libtorrent const std::string& comment() const { return m_comment; } - // dht nodes to add to the routing table/bootstrap from - using nodes_t = std::vector>; - // If this torrent contains any DHT nodes, they are put in this vector in // their original form (host name and port number). - nodes_t const& nodes() const + std::vector> const& nodes() const { return m_nodes; } // This is used when creating torrent. Use this to add a known DHT node. @@ -551,7 +548,8 @@ namespace libtorrent // the urls to the trackers std::vector m_urls; std::vector m_web_seeds; - nodes_t m_nodes; + // dht nodes to add to the routing table/bootstrap from + std::vector> m_nodes; // the info-hashes (20 bytes each) in the "similar" key. The pointers // point directly into the info_section. When copied, these pointers must diff --git a/src/create_torrent.cpp b/src/create_torrent.cpp index 315856a99..5860f7626 100644 --- a/src/create_torrent.cpp +++ b/src/create_torrent.cpp @@ -395,10 +395,8 @@ namespace libtorrent if (!ti.creator().empty()) set_creator(ti.creator().c_str()); if (!ti.comment().empty()) set_comment(ti.comment().c_str()); - torrent_info::nodes_t const& nodes = ti.nodes(); - for (torrent_info::nodes_t::const_iterator i = nodes.begin() - , end(nodes.end()); i != end; ++i) - add_node(*i); + for (auto const& n : ti.nodes()) + add_node(n); std::vector const& trackers = ti.trackers(); for (std::vector::const_iterator i = trackers.begin() diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 44e3510bc..744d193b4 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -4655,12 +4655,8 @@ namespace aux { #ifndef TORRENT_DISABLE_DHT if (params.ti) { - torrent_info::nodes_t const& nodes = params.ti->nodes(); - for (std::vector >::const_iterator i = nodes.begin() - , end(nodes.end()); i != end; ++i) - { - add_dht_node_name(*i); - } + for (auto const& n : params.ti->nodes()) + add_dht_node_name(n); } #endif