clean up some dead code and fix windows build

This commit is contained in:
Arvid Norberg 2011-02-28 00:35:58 +00:00
parent c15880be91
commit 08c93978a6
6 changed files with 14 additions and 41 deletions

View File

@ -170,7 +170,7 @@ namespace libtorrent
// 48 // 48
struct TORRENT_EXPORT peer struct TORRENT_EXPORT peer
{ {
peer(); // peer();
peer(boost::uint16_t port, bool connectable, int src); peer(boost::uint16_t port, bool connectable, int src);
size_type total_download() const; size_type total_download() const;
@ -325,7 +325,6 @@ namespace libtorrent
struct TORRENT_EXPORT ipv4_peer : peer struct TORRENT_EXPORT ipv4_peer : peer
{ {
ipv4_peer(tcp::endpoint const& ip, bool connectable, int src); ipv4_peer(tcp::endpoint const& ip, bool connectable, int src);
ipv4_peer(libtorrent::address const& a);
address_v4 addr; address_v4 addr;
}; };
@ -334,7 +333,6 @@ namespace libtorrent
struct TORRENT_EXPORT i2p_peer : peer struct TORRENT_EXPORT i2p_peer : peer
{ {
i2p_peer(char const* destination, bool connectable, int src); i2p_peer(char const* destination, bool connectable, int src);
i2p_peer(char const* destination);
~i2p_peer(); ~i2p_peer();
char* destination; char* destination;
@ -345,7 +343,6 @@ namespace libtorrent
struct TORRENT_EXPORT ipv6_peer : peer struct TORRENT_EXPORT ipv6_peer : peer
{ {
ipv6_peer(tcp::endpoint const& ip, bool connectable, int src); ipv6_peer(tcp::endpoint const& ip, bool connectable, int src);
ipv6_peer(libtorrent::address const& a);
address_v6::bytes_type addr; address_v6::bytes_type addr;
}; };
@ -475,19 +472,8 @@ namespace libtorrent
inline policy::ipv4_peer::ipv4_peer( inline policy::ipv4_peer::ipv4_peer(
tcp::endpoint const& ep, bool c, int src tcp::endpoint const& ep, bool c, int src
) )
: peer(ep.port(), c, src) : peer(ep.port(), c, src)
, addr(ep.address().to_v4()) , addr(ep.address().to_v4())
{
#if TORRENT_USE_IPV6
is_v6_addr = false;
#endif
#if TORRENT_USE_I2P
is_i2p_addr = false;
#endif
}
inline policy::ipv4_peer::ipv4_peer(libtorrent::address const& a)
: addr(a.to_v4())
{ {
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
is_v6_addr = false; is_v6_addr = false;
@ -506,14 +492,6 @@ namespace libtorrent
#endif #endif
is_i2p_addr = true; is_i2p_addr = true;
} }
inline policy::i2p_peer::i2p_peer(char const* dest)
: destination(strdup(dest))
{
#if TORRENT_USE_IPV6
is_v6_addr = false;
#endif
is_i2p_addr = true;
}
inline policy::i2p_peer::~i2p_peer() inline policy::i2p_peer::~i2p_peer()
{ free(destination); } { free(destination); }
@ -523,8 +501,8 @@ namespace libtorrent
inline policy::ipv6_peer::ipv6_peer( inline policy::ipv6_peer::ipv6_peer(
tcp::endpoint const& ep, bool c, int src tcp::endpoint const& ep, bool c, int src
) )
: peer(ep.port(), c, src) : peer(ep.port(), c, src)
, addr(ep.address().to_v6().to_bytes()) , addr(ep.address().to_v6().to_bytes())
{ {
is_v6_addr = true; is_v6_addr = true;
#if TORRENT_USE_I2P #if TORRENT_USE_I2P
@ -532,14 +510,6 @@ namespace libtorrent
#endif #endif
} }
inline policy::ipv6_peer::ipv6_peer(libtorrent::address const& a)
: addr(a.to_v6().to_bytes())
{
is_v6_addr = true;
#if TORRENT_USE_I2P
is_i2p_addr = false;
#endif
}
#endif // TORRENT_USE_IPV6 #endif // TORRENT_USE_IPV6
#if TORRENT_USE_I2P #if TORRENT_USE_I2P

View File

@ -623,9 +623,6 @@ namespace libtorrent
: m_done(false) : m_done(false)
{ {
ec.clear(); ec.clear();
memset(&m_dirent, 0, sizeof(dirent));
m_name[0] = 0;
#ifdef TORRENT_WINDOWS #ifdef TORRENT_WINDOWS
// the path passed to FindFirstFile() must be // the path passed to FindFirstFile() must be
// a pattern // a pattern
@ -647,6 +644,10 @@ namespace libtorrent
return; return;
} }
#else #else
memset(&m_dirent, 0, sizeof(dirent));
m_name[0] = 0;
// the path passed to opendir() may not // the path passed to opendir() may not
// end with a / // end with a /
std::string p = path; std::string p = path;

View File

@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/alert_types.hpp" #include "libtorrent/alert_types.hpp"
#include "libtorrent/alert.hpp" #include "libtorrent/alert.hpp"
#include "libtorrent/socket.hpp" #include "libtorrent/socket.hpp"
#include "libtorrent/random.hpp"
#include "libtorrent/aux_/session_impl.hpp" #include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/kademlia/node_id.hpp" #include "libtorrent/kademlia/node_id.hpp"
#include "libtorrent/kademlia/rpc_manager.hpp" #include "libtorrent/kademlia/rpc_manager.hpp"
@ -555,7 +556,7 @@ bool node_impl::lookup_peers(sha1_hash const& info_hash, int prefix, entry& repl
while (m < num) while (m < num)
{ {
if ((std::rand() / (RAND_MAX + 1.f)) * (num - t) >= num - m) if ((random() / float(UINT_MAX + 1.f)) * (num - t) >= num - m)
{ {
++iter; ++iter;
++t; ++t;

View File

@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
extern "C" { extern "C" {
#include "libtorrent/tommath.h" #include "libtorrent/tommath.h"
} }
#include "libtorrent/random.hpp"
#endif #endif
#include "libtorrent/pe_crypto.hpp" #include "libtorrent/pe_crypto.hpp"

View File

@ -4890,7 +4890,7 @@ namespace aux {
if (m_external_addresses.size() > 20) if (m_external_addresses.size() > 20)
{ {
if (random() < RAND_MAX / 2) if (random() < UINT_MAX / 2)
{ {
#if defined TORRENT_VERBOSE_LOGGING #if defined TORRENT_VERBOSE_LOGGING
(*m_logger) << time_now_string() << ": More than 20 slots, dopped\n"; (*m_logger) << time_now_string() << ": More than 20 slots, dopped\n";

View File

@ -391,7 +391,7 @@ namespace libtorrent { namespace
void failed_hash_check(ptime const& now) void failed_hash_check(ptime const& now)
{ {
m_request_limit = now + seconds(20 + (random() * 50) / RAND_MAX); m_request_limit = now + seconds(20 + (boost::int64_t(random()) * 50) / UINT_MAX);
} }
private: private: