From b7642f75d5304c371e1afd9daeef6a44df53bb44 Mon Sep 17 00:00:00 2001 From: arvidn Date: Tue, 20 Jun 2017 22:44:57 -0400 Subject: [PATCH] move clear_bufs out of storage.cpp into storage_utils --- include/libtorrent/aux_/storage_utils.hpp | 3 ++- include/libtorrent/storage.hpp | 2 -- src/storage.cpp | 8 +------- src/storage_utils.cpp | 6 ++++++ test/test_storage.cpp | 3 ++- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/libtorrent/aux_/storage_utils.hpp b/include/libtorrent/aux_/storage_utils.hpp index 7827bbb0e..0b5ed9fa7 100644 --- a/include/libtorrent/aux_/storage_utils.hpp +++ b/include/libtorrent/aux_/storage_utils.hpp @@ -53,11 +53,12 @@ namespace libtorrent { // operations using iovec_t = span; - namespace aux { +namespace aux { TORRENT_EXTRA_EXPORT int copy_bufs(span bufs , int bytes, span target); TORRENT_EXTRA_EXPORT typed_span advance_bufs(typed_span bufs, int bytes); + TORRENT_EXTRA_EXPORT void clear_bufs(span bufs); // this is a read or write operation so that readwritev() knows // what to do when it's actually touching the file diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index c6b32a9a7..db2e6c64a 100644 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -133,8 +133,6 @@ namespace libtorrent { namespace aux { struct session_settings; } struct add_torrent_params; - TORRENT_EXTRA_EXPORT void clear_bufs(span bufs); - struct disk_io_thread; // The storage interface is a pure virtual class that can be implemented to diff --git a/src/storage.cpp b/src/storage.cpp index 0d9bb70c2..d6e37ffce 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -77,12 +77,6 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - void clear_bufs(span 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); } diff --git a/src/storage_utils.cpp b/src/storage_utils.cpp index e0be719e9..2a66dc8d1 100644 --- a/src/storage_utils.cpp +++ b/src/storage_utils.cpp @@ -79,6 +79,12 @@ namespace libtorrent { namespace aux { } } + void clear_bufs(span bufs) + { + for (auto buf : bufs) + std::memset(buf.data(), 0, buf.size()); + } + #if TORRENT_USE_ASSERTS namespace { diff --git a/test/test_storage.cpp b/test/test_storage.cpp index 08dfb2a90..849d742db 100644 --- a/test/test_storage.cpp +++ b/test/test_storage.cpp @@ -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 #include @@ -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])