diff --git a/bindings/python/src/alert.cpp b/bindings/python/src/alert.cpp index a39f7712f..cde20e0a8 100644 --- a/bindings/python/src/alert.cpp +++ b/bindings/python/src/alert.cpp @@ -198,8 +198,7 @@ list dht_get_peers_reply_alert_peers(dht_get_peers_reply_alert const& a) { list result; - std::vector v; - a.peers(v); + std::vector v(a.peers()); for (std::vector::const_iterator i = v.begin(); i != v.end(); ++i) diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 06ee4cb44..9b884ccbb 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -2403,7 +2403,12 @@ namespace libtorrent sha1_hash info_hash; int num_peers() const; - void peers(std::vector& peers) const; + +#ifndef TORRENT_NO_DEPRECATE + TORRENT_DEPRECATED + void peers(std::vector& v) const; +#endif + std::vector peers() const; private: aux::stack_allocator& m_alloc; diff --git a/include/libtorrent/aux_/proxy_settings.hpp b/include/libtorrent/aux_/proxy_settings.hpp index dbaa15467..19e9de6b3 100644 --- a/include/libtorrent/aux_/proxy_settings.hpp +++ b/include/libtorrent/aux_/proxy_settings.hpp @@ -63,7 +63,7 @@ namespace aux { // set to authenticate with the proxy. std::string hostname; - // when using a proy type that requires authentication, the username + // when using a proxy type that requires authentication, the username // and password fields must be set to the credentials for the proxy. std::string username; std::string password; @@ -128,7 +128,7 @@ namespace aux { // This is only supported by SOCKS5 and HTTP. bool proxy_hostnames; - // determines whether or not to excempt peer and web seed connections + // determines whether or not to exempt peer and web seed connections // from using the proxy. This defaults to true, i.e. peer connections are // proxied by default. bool proxy_peer_connections; diff --git a/src/alert.cpp b/src/alert.cpp index 076beb0e2..1b64d70d6 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -1918,17 +1918,24 @@ namespace libtorrent { return m_num_peers; } - void dht_get_peers_reply_alert::peers(std::vector& peers) const - { - peers.resize(m_num_peers); +#ifndef TORRENT_NO_DEPRECATE + void dht_get_peers_reply_alert::peers(std::vector &v) const { + std::vector p(peers()); + v.reserve(p.size()); + std::copy(p.begin(), p.end(), std::back_inserter(v)); + } +#endif + std::vector dht_get_peers_reply_alert::peers() const { + std::vector peers(m_num_peers); const char *ptr = m_alloc.ptr(m_peers_idx); for (int i = 0; i < m_num_peers; i++) { - std::size_t size = detail::read_uint8(ptr); memcpy(peers[i].data(), ptr, size); ptr += size; } + + return peers; } dht_direct_response_alert::dht_direct_response_alert(