fixed windows build and removed msvc warnings

This commit is contained in:
Arvid Norberg 2008-02-25 10:28:53 +00:00
parent a20a8d2522
commit a25c25b02a
12 changed files with 28 additions and 22 deletions

View File

@ -1038,7 +1038,7 @@ The ``torrent_info`` has the following synopsis::
std::vector<std::string> const& url_seeds() const;
size_type total_size() const;
size_type piece_length() const;
int piece_length() const;
int num_pieces() const;
sha1_hash const& info_hash() const;
std::string const& name() const;
@ -1053,7 +1053,7 @@ The ``torrent_info`` has the following synopsis::
void print(std::ostream& os) const;
size_type piece_size(unsigned int index) const;
int piece_size(unsigned int index) const;
sha1_hash const& hash_for_piece(unsigned int index) const;
};
@ -1370,8 +1370,8 @@ total_size() piece_length() piece_size() num_pieces()
::
size_type total_size() const;
size_type piece_length() const;
size_type piece_size(unsigned int index) const;
int piece_length() const;
int piece_size(unsigned int index) const;
int num_pieces() const;

View File

@ -139,6 +139,8 @@ struct bandwidth_manager
void close()
{
m_abort = true;
m_queue.clear();
m_history.clear();
m_history_timer.cancel();
}
@ -192,6 +194,7 @@ struct bandwidth_manager
{
mutex_t::scoped_lock l(m_mutex);
INVARIANT_CHECK;
if (m_abort) return;
TORRENT_ASSERT(blk > 0);
TORRENT_ASSERT(!is_queued(peer.get(), l));
TORRENT_ASSERT(!peer->ignore_bandwidth_limits());

View File

@ -57,7 +57,7 @@ namespace libtorrent
{
struct http_connection;
struct connection_queue;
class connection_queue;
typedef boost::function<void(asio::error_code const&
, http_parser const&, char const* data, int size)> http_handler;

View File

@ -198,7 +198,7 @@ namespace libtorrent
const std::vector<announce_entry>& trackers() const { return m_urls; }
size_type total_size() const { TORRENT_ASSERT(m_piece_length > 0); return m_total_size; }
size_type piece_length() const { TORRENT_ASSERT(m_piece_length > 0); return m_piece_length; }
int piece_length() const { TORRENT_ASSERT(m_piece_length > 0); return m_piece_length; }
int num_pieces() const { TORRENT_ASSERT(m_piece_length > 0); return m_num_pieces; }
const sha1_hash& info_hash() const { return m_info_hash; }
const std::string& name() const { TORRENT_ASSERT(m_piece_length > 0); return m_name; }
@ -215,7 +215,7 @@ namespace libtorrent
void convert_file_names();
size_type piece_size(int index) const;
int piece_size(int index) const;
const sha1_hash& hash_for_piece(int index) const
{
@ -267,7 +267,7 @@ namespace libtorrent
// the length of one piece
// if this is 0, the torrent_info is
// in an uninitialized state
size_type m_piece_length;
int m_piece_length;
// the sha-1 hashes of each piece
std::vector<sha1_hash> m_piece_hash;

View File

@ -1265,7 +1265,7 @@ namespace libtorrent
if (listen_port->type() == entry::int_t
&& peer_info_struct() != 0)
{
t->get_policy().update_peer_port(listen_port->integer()
t->get_policy().update_peer_port(int(listen_port->integer())
, peer_info_struct(), peer_info::incoming);
}
}
@ -1281,7 +1281,7 @@ namespace libtorrent
if (entry* reqq = root.find_key("reqq"))
{
if (reqq->type() == entry::int_t)
m_max_out_request_queue = reqq->integer();
m_max_out_request_queue = int(reqq->integer());
if (m_max_out_request_queue < 1)
m_max_out_request_queue = 1;
}

View File

@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <sstream>
#include <windows.h>
#include <winioctl.h>
#include <boost/scoped_ptr.hpp>
namespace
{

View File

@ -630,6 +630,8 @@ namespace detail
if (m_dht) m_dht->stop();
m_dht_socket.close();
#endif
m_download_channel.close();
m_upload_channel.close();
m_timer.cancel();
// close the listen sockets

View File

@ -592,7 +592,7 @@ namespace libtorrent
|| pair.back().type() != entry::int_t)
break;
file_sizes.push_back(std::pair<size_type, std::time_t>(
pair.front().integer(), pair.back().integer()));
pair.front().integer(), std::time_t(pair.back().integer())));
}
if (file_sizes.empty())
@ -1905,8 +1905,8 @@ namespace libtorrent
num_pieces = 0;
}
m_piece_data.resize(int(m_info->piece_length()));
int piece_size = int(m_info->piece_size(m_current_slot));
m_piece_data.resize(m_info->piece_length());
int piece_size = m_info->piece_size(m_current_slot);
int num_read = m_storage->read(&m_piece_data[0]
, m_current_slot, 0, piece_size);
@ -2010,7 +2010,7 @@ namespace libtorrent
bool ret = false;
if (piece_index >= 0)
{
ret |= m_piece_to_slot[piece_index] = other_slot;
m_piece_to_slot[piece_index] = other_slot;
ret |= m_storage->swap_slots(other_slot, m_current_slot);
}
else

View File

@ -3126,8 +3126,8 @@ namespace libtorrent
size_type done = 0;
while (size > 0)
{
size_type bytes_step = (std::min)(m_torrent_file->piece_size(ret.piece)
- ret.start, size);
size_type bytes_step = (std::min)(size_type(m_torrent_file->piece_size(ret.piece)
- ret.start), size);
if (m_have_pieces[ret.piece]) done += bytes_step;
++ret.piece;
ret.start = 0;

View File

@ -886,13 +886,13 @@ namespace libtorrent
// ------- end deprecation -------
size_type torrent_info::piece_size(int index) const
int torrent_info::piece_size(int index) const
{
TORRENT_ASSERT(index >= 0 && index < num_pieces());
if (index == num_pieces()-1)
{
size_type size = total_size()
- (num_pieces() - 1) * piece_length();
int size = int(total_size()
- (num_pieces() - 1) * piece_length());
TORRENT_ASSERT(size > 0);
TORRENT_ASSERT(size <= piece_length());
return size;

View File

@ -474,7 +474,7 @@ namespace libtorrent
// we should not try this server again.
t->remove_url_seed(m_url);
std::stringstream msg;
msg << "invalid range in HTTP response: " << range_str;
msg << "invalid range in HTTP response: " << range_str.str();
disconnect(msg.str().c_str());
return;
}
@ -507,7 +507,7 @@ namespace libtorrent
int file_index = m_file_requests.front();
peer_request in_range = info.map_file(file_index, range_start
, range_end - range_start);
, int(range_end - range_start));
peer_request front_request = m_requests.front();

View File

@ -316,7 +316,7 @@ int test_main()
int dist = distance_exp(a, b);
TEST_CHECK(dist >= 0 && dist < 160);
TEST_CHECK(dist == ((i == j)?0:std::max(i, j)));
TEST_CHECK(dist == ((i == j)?0:(std::max)(i, j)));
for (int k = 0; k < 160; k += 4)
{