Fix sizeof(X)/sizeof(T) and _countof (#1189)

https://msdn.microsoft.com/en-us/library/ms175773.aspx
 http://www.viva64.com/en/w/V651/print/
This commit is contained in:
Pavel Pimenov 2016-10-07 00:45:35 +03:00 committed by Arvid Norberg
parent 5c361715da
commit af2a9a875b
1 changed files with 3 additions and 6 deletions

View File

@ -40,8 +40,7 @@ namespace libtorrent {
counters::counters()
{
#ifdef ATOMIC_LLONG_LOCK_FREE
for (int i = 0; i < sizeof(m_stats_counter)
/ sizeof(m_stats_counter[0]); ++i)
for (int i = 0; i < m_stats_counter.size(); ++i)
m_stats_counter[i].store(0, std::memory_order_relaxed);
#else
memset(m_stats_counter, 0, sizeof(m_stats_counter));
@ -51,8 +50,7 @@ namespace libtorrent {
counters::counters(counters const& c)
{
#ifdef ATOMIC_LLONG_LOCK_FREE
for (int i = 0; i < sizeof(m_stats_counter)
/ sizeof(m_stats_counter[0]); ++i)
for (int i = 0; i < m_stats_counter.size(); ++i)
m_stats_counter[i].store(
c.m_stats_counter[i].load(std::memory_order_relaxed)
, std::memory_order_relaxed);
@ -65,8 +63,7 @@ namespace libtorrent {
counters& counters::operator=(counters const& c)
{
#ifdef ATOMIC_LLONG_LOCK_FREE
for (int i = 0; i < sizeof(m_stats_counter)
/ sizeof(m_stats_counter[0]); ++i)
for (int i = 0; i < m_stats_counter.size(); ++i)
m_stats_counter[i].store(
c.m_stats_counter[i].load(std::memory_order_relaxed)
, std::memory_order_relaxed);