forked from premiere/premiere-libtorrent
fixes to make valgrind happy
This commit is contained in:
parent
3474346a3d
commit
8cec51fc47
|
@ -43,11 +43,11 @@ namespace libtorrent
|
|||
struct TORRENT_EXPORT bitfield
|
||||
{
|
||||
bitfield(): m_bytes(0), m_size(0), m_own(false) {}
|
||||
bitfield(int bits): m_bytes(0), m_size(0)
|
||||
bitfield(int bits): m_bytes(0), m_size(0), m_own(false)
|
||||
{ resize(bits); }
|
||||
bitfield(int bits, bool val): m_bytes(0), m_size(0)
|
||||
bitfield(int bits, bool val): m_bytes(0), m_size(0), m_own(false)
|
||||
{ resize(bits, val); }
|
||||
bitfield(char const* b, int bits): m_bytes(0), m_size(0)
|
||||
bitfield(char const* b, int bits): m_bytes(0), m_size(0), m_own(false)
|
||||
{ assign(b, bits); }
|
||||
bitfield(bitfield const& rhs): m_bytes(0), m_size(0), m_own(false)
|
||||
{ assign(rhs.bytes(), rhs.size()); }
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace libtorrent
|
|||
public:
|
||||
enum { size = number_size };
|
||||
|
||||
big_number() {}
|
||||
big_number() { clear(); }
|
||||
|
||||
static big_number max()
|
||||
{
|
||||
|
@ -101,15 +101,8 @@ namespace libtorrent
|
|||
std::memcpy(m_number, s.c_str(), sl);
|
||||
}
|
||||
|
||||
void assign(char const* str)
|
||||
{
|
||||
std::memcpy(m_number, str, size);
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
std::fill(m_number,m_number+number_size,(const unsigned char)(0));
|
||||
}
|
||||
void assign(char const* str) { std::memcpy(m_number, str, size); }
|
||||
void clear() { std::memset(m_number, 0, number_size); }
|
||||
|
||||
bool is_all_zeros() const
|
||||
{
|
||||
|
|
|
@ -66,6 +66,11 @@ using libtorrent::aux::session_impl;
|
|||
|
||||
namespace libtorrent
|
||||
{
|
||||
int round_up8(int v)
|
||||
{
|
||||
return ((v & 7) == 0) ? v : v + (8 - (v & 7));
|
||||
}
|
||||
|
||||
// outbound connection
|
||||
peer_connection::peer_connection(
|
||||
session_impl& ses
|
||||
|
@ -4630,7 +4635,7 @@ namespace libtorrent
|
|||
int regular_buffer_size = m_packet_size - m_disk_recv_buffer_size;
|
||||
|
||||
if (int(m_recv_buffer.size()) < regular_buffer_size)
|
||||
m_recv_buffer.resize(regular_buffer_size);
|
||||
m_recv_buffer.resize(round_up8(regular_buffer_size));
|
||||
|
||||
boost::array<asio::mutable_buffer, 2> vec;
|
||||
int num_bufs = 0;
|
||||
|
@ -4938,7 +4943,8 @@ namespace libtorrent
|
|||
&& m_recv_pos == 0
|
||||
&& (m_recv_buffer.capacity() - m_packet_size) > 128)
|
||||
{
|
||||
buffer(m_packet_size).swap(m_recv_buffer);
|
||||
// round up to an even 8 bytes since that's the RC4 blocksize
|
||||
buffer(round_up8(m_packet_size)).swap(m_recv_buffer);
|
||||
}
|
||||
|
||||
if (m_recv_pos >= m_soft_packet_size) m_soft_packet_size = 0;
|
||||
|
|
Loading…
Reference in New Issue