move clear_bufs out of storage.cpp into storage_utils

This commit is contained in:
arvidn 2017-06-20 22:44:57 -04:00 committed by Arvid Norberg
parent 2af4e936c4
commit b7642f75d5
5 changed files with 11 additions and 11 deletions

View File

@ -53,11 +53,12 @@ namespace libtorrent {
// operations
using iovec_t = span<char>;
namespace aux {
namespace aux {
TORRENT_EXTRA_EXPORT int copy_bufs(span<iovec_t const> bufs
, int bytes, span<iovec_t> target);
TORRENT_EXTRA_EXPORT typed_span<iovec_t> advance_bufs(typed_span<iovec_t> bufs, int bytes);
TORRENT_EXTRA_EXPORT void clear_bufs(span<iovec_t const> bufs);
// this is a read or write operation so that readwritev() knows
// what to do when it's actually touching the file

View File

@ -133,8 +133,6 @@ namespace libtorrent {
namespace aux { struct session_settings; }
struct add_torrent_params;
TORRENT_EXTRA_EXPORT void clear_bufs(span<iovec_t const> bufs);
struct disk_io_thread;
// The storage interface is a pure virtual class that can be implemented to

View File

@ -77,12 +77,6 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent {
void clear_bufs(span<iovec_t const> bufs)
{
for (auto buf : bufs)
std::memset(buf.data(), 0, buf.size());
}
default_storage::default_storage(storage_params const& params
, file_pool& pool)
: storage_interface(params.files)
@ -478,7 +472,7 @@ namespace libtorrent {
if (files().pad_file_at(file_index))
{
// reading from a pad file yields zeroes
clear_bufs(vec);
aux::clear_bufs(vec);
return bufs_size(vec);
}

View File

@ -79,6 +79,12 @@ namespace libtorrent { namespace aux {
}
}
void clear_bufs(span<iovec_t const> bufs)
{
for (auto buf : bufs)
std::memset(buf.data(), 0, buf.size());
}
#if TORRENT_USE_ASSERTS
namespace {

View File

@ -46,6 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/read_resume_data.hpp"
#include "libtorrent/write_resume_data.hpp"
#include "libtorrent/aux_/path.hpp"
#include "libtorrent/aux_/storage_utils.hpp"
#include <iostream>
#include <fstream>
@ -1037,7 +1038,7 @@ TORRENT_TEST(iovec_clear_bufs)
alloc_iov(iov, 10);
fill_pattern(iov, 10);
clear_bufs({iov, 10});
lt::aux::clear_bufs({iov, 10});
for (int i = 0; i < 10; ++i)
{
for (char v : iov[i])