refactor in buffer.hpp to not use anonymous namespace in header (#1192)

refactor in buffer.hpp to not use anonymous namespace in header
This commit is contained in:
Alden Torres 2016-10-08 01:12:34 -04:00 committed by Arvid Norberg
parent 7f060e4a70
commit f580fcaa67
3 changed files with 6 additions and 11 deletions

View File

@ -35,7 +35,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/assert.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/buffer.hpp"
#include "libtorrent/aux_/byteswap.hpp"
#include "libtorrent/aux_/ffs.hpp"

View File

@ -52,13 +52,6 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent {
namespace {
inline std::size_t round_up8(std::size_t const v)
{
return (v + 7) & (~std::size_t(0x7));
}
}
// the buffer is allocated once and cannot be resized. The size() may be
// larger than requested, in case the underlying allocator over allocated. In
// order to "grow" an allocation, create a new buffer and initialize it by
@ -75,7 +68,10 @@ public:
if (size == 0) return;
size = round_up8(size);
// this rounds up the size to be 8 bytes aligned
// it mostly makes sense for platforms without support
// for a variation of "malloc_size()"
size = (size + 7) & (~std::size_t(0x7));
m_begin = static_cast<char*>(std::malloc(size));
if (m_begin == nullptr)
@ -108,7 +104,7 @@ public:
TORRENT_ASSERT(initialize.size() <= size);
if (initialize.size() > 0)
{
memcpy(m_begin, initialize.data(), (std::min)(initialize.size(), size));
std::memcpy(m_begin, initialize.data(), (std::min)(initialize.size(), size));
}
}

View File

@ -142,7 +142,7 @@ void web_peer_connection::on_connected()
// only advertise pieces that are contained within the files we have as
// indicated by m_web->have_files AND padfiles!
// it's important to include pieces that may overlap many files, as long
// as we have all those files, so instead of starting with a clear bitfied
// as we have all those files, so instead of starting with a clear bitfield
// and setting the pieces corresponding to files we have, we do it the
// other way around. Start with assuming we have all files, and clear
// pieces overlapping with files we *don't* have.