Skip to content

Commit

Permalink
settle on using std::fill()
Browse files Browse the repository at this point in the history
  • Loading branch information
pnorbert committed Dec 9, 2020
1 parent 6520d80 commit 2768796
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions source/adios2/toolkit/format/buffer/heap/BufferSTL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,25 @@ void BufferSTL::Reset(const bool resetAbsolutePosition,
}
if (zeroInitialize)
{
// m_Buffer.assign(m_Buffer.size(), '\0');
// memset(static_cast<void *>(&m_Buffer[0]), 0, m_Buffer.size());
std::fill(m_Buffer.begin(), m_Buffer.end(), 0);
}
/* else
else
{
// just zero out the first and last 1kb
const size_t bufsize = m_Buffer.size();
size_t s = (bufsize < 1024 ? bufsize : 1024);
std::fill_n(m_Buffer.begin(), s, 0);
if (bufsize > 1024)
{
// just zero out the first and last 1kb
const size_t bufsize = m_Buffer.size();
size_t s = (bufsize < 1024 ? bufsize : 1024);
memset(static_cast<void *>(&m_Buffer[0]), 0, s);
if (bufsize > 1024)
size_t pos = bufsize - 1024;
if (pos < 1024)
{
size_t pos = bufsize - 1024;
if (pos < 1024)
{
pos = 1024;
}
s = bufsize - pos;
memset(static_cast<void *>(&m_Buffer[pos]), 0, s);
pos = 1024;
}
}*/
s = bufsize - pos;
std::fill_n(next(m_Buffer.begin(), pos), s, 0);
}
}
}

size_t BufferSTL::GetAvailableSize() const
Expand Down

0 comments on commit 2768796

Please sign in to comment.