dccl-dev team mailing list archive
-
dccl-dev team
-
Mailing list archive
-
Message #00021
[Merge] lp:~nknotts/dccl/fill_n into lp:dccl
Nathan Knotts has proposed merging lp:~nknotts/dccl/fill_n into lp:dccl.
Requested reviews:
DCCL Developers (dccl-dev)
For more details, see:
https://code.launchpad.net/~nknotts/dccl/fill_n/+merge/251376
In http://bazaar.launchpad.net/~dccl-dev/dccl/3.0/revision/314, I used std::memset to zero-initialize the byte string. This compiled and worked for me on OS X/clang 3.5. I began testing on Ubuntu 14.04/Centos7 (gcc 4.8) and the std::memset was not found because of a missing <cstring> include. Instead of adding the <cstring> include, I switched to using std::fill_n because <algorithm> is already included and std::fill_n is a slightly higher level call. Also, this stack overflow post, http://stackoverflow.com/questions/1373369/which-is-faster-preferred-memset-or-for-loop-to-zero-out-an-array-of-doubles, seems to prefer std::fill as it is more modern/C++ then std::memset.
--
Your team DCCL Developers is requested to review the proposed merge of lp:~nknotts/dccl/fill_n into lp:dccl.
=== modified file 'src/bitset.h'
--- src/bitset.h 2015-01-26 14:51:34 +0000
+++ src/bitset.h 2015-02-28 23:01:29 +0000
@@ -333,7 +333,7 @@
assert( max_len >= len );
// initialize buffer to all zeroes
- std::memset(buf, 0, len);
+ std::fill_n(buf, len, 0);
for(size_type i = 0, n = this->size(); i < n; ++i)
buf[i/8] |= static_cast<char>((*this)[i] << (i%8));
Follow ups