From 04393991692a367665b1b907fd7b5cd0b9a429f3 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 30 Oct 2007 17:30:49 +0000 Subject: [PATCH] replaced std::vector with buffer --- include/libtorrent/storage.hpp | 5 +++-- src/storage.cpp | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/libtorrent/storage.hpp b/include/libtorrent/storage.hpp index 68a81c75b..a3f97b589 100755 --- a/include/libtorrent/storage.hpp +++ b/include/libtorrent/storage.hpp @@ -57,6 +57,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_request.hpp" #include "libtorrent/hasher.hpp" #include "libtorrent/config.hpp" +#include "libtorrent/buffer.hpp" namespace libtorrent { @@ -344,8 +345,8 @@ namespace libtorrent // used to move pieces while expanding // the storage from compact allocation // to full allocation - std::vector m_scratch_buffer; - std::vector m_scratch_buffer2; + buffer m_scratch_buffer; + buffer m_scratch_buffer2; // the piece that is in the scratch buffer int m_scratch_piece; diff --git a/src/storage.cpp b/src/storage.cpp index 80eaf8a8e..0468684f3 100755 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -99,6 +99,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include "libtorrent/utf8.hpp" +#include "libtorrent/buffer.hpp" namespace libtorrent { @@ -386,7 +387,7 @@ namespace libtorrent file_pool& m_files; // temporary storage for moving pieces - std::vector m_scratch_buffer; + buffer m_scratch_buffer; }; sha1_hash storage::hash_for_slot(int slot, partial_hash& ph, int piece_size) @@ -468,14 +469,14 @@ namespace libtorrent void storage::release_files() { m_files.release(this); - std::vector().swap(m_scratch_buffer); + buffer().swap(m_scratch_buffer); } void storage::delete_files() { // make sure we don't have the files open m_files.release(this); - std::vector().swap(m_scratch_buffer); + buffer().swap(m_scratch_buffer); // delete the files from disk std::set directories; @@ -1623,8 +1624,8 @@ namespace libtorrent if (m_current_slot == m_info->num_pieces()) { m_state = state_create_files; - std::vector().swap(m_scratch_buffer); - std::vector().swap(m_scratch_buffer2); + buffer().swap(m_scratch_buffer); + buffer().swap(m_scratch_buffer2); if (m_storage_mode != storage_mode_compact) { std::vector().swap(m_piece_to_slot);