replaced std::vector with buffer

This commit is contained in:
Arvid Norberg 2007-10-30 17:30:49 +00:00
parent e28689237d
commit 0439399169
2 changed files with 9 additions and 7 deletions

View File

@ -57,6 +57,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/peer_request.hpp" #include "libtorrent/peer_request.hpp"
#include "libtorrent/hasher.hpp" #include "libtorrent/hasher.hpp"
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#include "libtorrent/buffer.hpp"
namespace libtorrent namespace libtorrent
{ {
@ -344,8 +345,8 @@ namespace libtorrent
// used to move pieces while expanding // used to move pieces while expanding
// the storage from compact allocation // the storage from compact allocation
// to full allocation // to full allocation
std::vector<char> m_scratch_buffer; buffer m_scratch_buffer;
std::vector<char> m_scratch_buffer2; buffer m_scratch_buffer2;
// the piece that is in the scratch buffer // the piece that is in the scratch buffer
int m_scratch_piece; int m_scratch_piece;

View File

@ -99,6 +99,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <windows.h> #include <windows.h>
#include <boost/filesystem/exception.hpp> #include <boost/filesystem/exception.hpp>
#include "libtorrent/utf8.hpp" #include "libtorrent/utf8.hpp"
#include "libtorrent/buffer.hpp"
namespace libtorrent namespace libtorrent
{ {
@ -386,7 +387,7 @@ namespace libtorrent
file_pool& m_files; file_pool& m_files;
// temporary storage for moving pieces // temporary storage for moving pieces
std::vector<char> m_scratch_buffer; buffer m_scratch_buffer;
}; };
sha1_hash storage::hash_for_slot(int slot, partial_hash& ph, int piece_size) sha1_hash storage::hash_for_slot(int slot, partial_hash& ph, int piece_size)
@ -468,14 +469,14 @@ namespace libtorrent
void storage::release_files() void storage::release_files()
{ {
m_files.release(this); m_files.release(this);
std::vector<char>().swap(m_scratch_buffer); buffer().swap(m_scratch_buffer);
} }
void storage::delete_files() void storage::delete_files()
{ {
// make sure we don't have the files open // make sure we don't have the files open
m_files.release(this); m_files.release(this);
std::vector<char>().swap(m_scratch_buffer); buffer().swap(m_scratch_buffer);
// delete the files from disk // delete the files from disk
std::set<std::string> directories; std::set<std::string> directories;
@ -1623,8 +1624,8 @@ namespace libtorrent
if (m_current_slot == m_info->num_pieces()) if (m_current_slot == m_info->num_pieces())
{ {
m_state = state_create_files; m_state = state_create_files;
std::vector<char>().swap(m_scratch_buffer); buffer().swap(m_scratch_buffer);
std::vector<char>().swap(m_scratch_buffer2); buffer().swap(m_scratch_buffer2);
if (m_storage_mode != storage_mode_compact) if (m_storage_mode != storage_mode_compact)
{ {
std::vector<int>().swap(m_piece_to_slot); std::vector<int>().swap(m_piece_to_slot);