formatting, added std:: and spaces

This commit is contained in:
Alden Torres 2016-12-10 20:51:55 -05:00 committed by Arvid Norberg
parent dd7179fb10
commit 3a92908f39
12 changed files with 62 additions and 61 deletions

View File

@ -37,6 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <vector>
#include <map>
#include <functional>
#include <ctime>
#include "libtorrent/storage_defs.hpp"
#include "libtorrent/sha1_hash.hpp"
@ -381,14 +382,14 @@ namespace libtorrent
// was first added, including previous runs/sessions. If set to zero, the
// internal added_time will be set to the time of when add_torrent() is
// called.
time_t added_time = 0;
time_t completed_time = 0;
std::time_t added_time = 0;
std::time_t completed_time = 0;
// if set to non-zero, initializes the time (expressed in posix time) when
// we last saw a seed or peers that together formed a complete copy of the
// torrent. If left set to zero, the internal counterpart to this field
// will be updated when we see a seed or a distributed copies >= 1.0.
time_t last_seen_complete = 0;
std::time_t last_seen_complete = 0;
// these field can be used to initialize the torrent's cached scrape data.
// The scrape data is high level metadata about the current state of the

View File

@ -462,7 +462,7 @@ namespace libtorrent
// index (given the piece size).
sha1_hash hash(int index) const;
std::string const& symlink(int index) const;
time_t mtime(int index) const;
std::time_t mtime(int index) const;
std::string file_path(int index, std::string const& save_path = "") const;
string_view file_name(int index) const;
std::int64_t file_size(int index) const;
@ -538,7 +538,7 @@ namespace libtorrent
TORRENT_DEPRECATED
std::string const& symlink(internal_file_entry const& fe) const;
TORRENT_DEPRECATED
time_t mtime(internal_file_entry const& fe) const;
std::time_t mtime(internal_file_entry const& fe) const;
TORRENT_DEPRECATED
int file_index(internal_file_entry const& fe) const;
TORRENT_DEPRECATED
@ -602,7 +602,7 @@ namespace libtorrent
// is empty if no file have a modification time.
// each element corresponds to the file with the same
// index in m_files
std::vector<time_t> m_mtime;
std::vector<std::time_t> m_mtime;
#ifndef TORRENT_NO_DEPRECATE
// if any file has a non-zero file base (i.e. multiple

View File

@ -166,11 +166,11 @@ namespace libtorrent
#define PROT_READ PAGE_READONLY
#define PROT_WRITE PAGE_READWRITE
#endif
const int page = page_size();
int const page = page_size();
// make the two surrounding pages non-readable and -writable
mprotect(block - page, page, PROT_READ | PROT_WRITE);
alloc_header* h = reinterpret_cast<alloc_header*>(block - page);
const int num_pages = int((h->size + (page-1)) / page + 2);
int const num_pages = int((h->size + (page - 1)) / page + 2);
TORRENT_ASSERT(h->magic == 0x1337);
mprotect(block + (num_pages - 2) * page, page, PROT_READ | PROT_WRITE);
// std::fprintf(stderr, "free: %p head: %p tail: %p size: %d\n", block, block - page, block + h->size, int(h->size));

View File

@ -294,7 +294,7 @@ namespace libtorrent
TORRENT_ASSERT(m_token_idx != -1);
bdecode_token const& t = m_root_tokens[m_token_idx];
bdecode_token const& next = m_root_tokens[m_token_idx + t.next_item];
return { m_buffer + t.offset, size_t(next.offset - t.offset) };
return {m_buffer + t.offset, std::size_t(next.offset - t.offset)};
}
bdecode_node bdecode_node::list_at(int i) const
@ -574,7 +574,7 @@ namespace libtorrent
{
TORRENT_ASSERT(type() == string_t);
bdecode_token const& t = m_root_tokens[m_token_idx];
size_t const size = m_root_tokens[m_token_idx + 1].offset - t.offset - t.start_offset();
std::size_t const size = m_root_tokens[m_token_idx + 1].offset - t.offset - t.start_offset();
TORRENT_ASSERT(t.type == bdecode_token::string);
return string_view(m_buffer + t.offset + t.start_offset(), size);

View File

@ -1196,7 +1196,7 @@ namespace libtorrent
int const file_flags = file_flags_for_job(j
, m_settings.get_bool(settings_pack::coalesce_reads));
file::iovec_t b = { j->buffer.disk_block, size_t(j->d.io.buffer_size) };
file::iovec_t b = {j->buffer.disk_block, std::size_t(j->d.io.buffer_size)};
int ret = j->storage->readv(b
, j->piece, j->d.io.offset, file_flags, j->error);
@ -1428,7 +1428,7 @@ namespace libtorrent
{
time_point const start_time = clock_type::now();
file::iovec_t const b = { j->buffer.disk_block, size_t(j->d.io.buffer_size) };
file::iovec_t const b = {j->buffer.disk_block, std::size_t(j->d.io.buffer_size)};
int const file_flags = file_flags_for_job(j
, m_settings.get_bool(settings_pack::coalesce_writes));

View File

@ -317,7 +317,7 @@ namespace libtorrent
string_view internal_file_entry::filename() const
{
if (name_len != name_is_owned) return { name, size_t(name_len) };
if (name_len != name_is_owned) return {name, std::size_t(name_len)};
return name ? string_view(name) : string_view();
}
@ -630,7 +630,7 @@ namespace libtorrent
return m_symlinks[fe.symlink_index];
}
time_t file_storage::mtime(int index) const
std::time_t file_storage::mtime(int index) const
{
if (index >= int(m_mtime.size())) return 0;
return m_mtime[index];
@ -865,7 +865,7 @@ namespace libtorrent
return m_symlinks[fe.symlink_index];
}
time_t file_storage::mtime(internal_file_entry const& fe) const
std::time_t file_storage::mtime(internal_file_entry const& fe) const
{
int index = int(&fe - &m_files[0]);
if (index >= int(m_mtime.size())) return 0;
@ -1113,7 +1113,7 @@ namespace libtorrent
std::vector<internal_file_entry>().swap(m_files);
std::vector<char const*>().swap(m_file_hashes);
std::vector<std::string>().swap(m_symlinks);
std::vector<time_t>().swap(m_mtime);
std::vector<std::time_t>().swap(m_mtime);
#ifndef TORRENT_NO_DEPRECATE
std::vector<std::int64_t>().swap(m_file_base);
#endif

View File

@ -94,7 +94,7 @@ namespace libtorrent
{
// parse header
std::unique_ptr<std::uint32_t[]> header(new std::uint32_t[m_header_size]);
file::iovec_t b = {header.get(), size_t(m_header_size) };
file::iovec_t b = {header.get(), std::size_t(m_header_size)};
int n = int(m_file.readv(0, b, ec));
if (ec) return;
@ -326,7 +326,7 @@ namespace libtorrent
// don't hold the lock during disk I/O
l.unlock();
file::iovec_t v = { buf.get(), size_t(block_to_copy) };
file::iovec_t v = {buf.get(), std::size_t(block_to_copy)};
v.iov_len = m_file.readv(slot_offset + piece_offset, v, ec);
TORRENT_ASSERT(!ec);
if (ec || v.iov_len == 0) return;
@ -412,7 +412,7 @@ namespace libtorrent
}
std::memset(ptr, 0, m_header_size - (ptr - reinterpret_cast<char*>(header.get())));
file::iovec_t b = {header.get(), size_t(m_header_size) };
file::iovec_t b = {header.get(), std::size_t(m_header_size)};
m_file.writev(0, b, ec);
if (ec) return;
}

View File

@ -1459,8 +1459,8 @@ namespace libtorrent
names.append(torrent_name, name_length);
#endif
if (strncmp(torrent_name, "*", name_length) == 0
|| strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0)
if (std::strncmp(torrent_name, "*", name_length) == 0
|| std::strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0)
{
#ifdef TORRENT_DISABLE_LOGGING
return true;

View File

@ -73,7 +73,7 @@ namespace libtorrent
{
token = xml_parse_error;
start = "unexpected end of file";
callback(token, start, int(strlen(start)), nullptr, 0);
callback(token, start, int(std::strlen(start)), nullptr, 0);
break;
}
@ -96,7 +96,7 @@ namespace libtorrent
{
token = xml_parse_error;
start = "unexpected end of file";
callback(token, start, int(strlen(start)), nullptr, 0);
callback(token, start, int(std::strlen(start)), nullptr, 0);
break;
}
@ -173,7 +173,7 @@ namespace libtorrent
{
token = xml_parse_error;
start = "unquoted attribute value";
callback(token, start, int(strlen(start)), nullptr, 0);
callback(token, start, int(std::strlen(start)), nullptr, 0);
break;
}
char quote = *i;
@ -185,7 +185,7 @@ namespace libtorrent
{
token = xml_parse_error;
start = "missing end quote on attribute";
callback(token, start, int(strlen(start)), nullptr, 0);
callback(token, start, int(std::strlen(start)), nullptr, 0);
break;
}
const int val_len = int(i - val_start);