bit_writer_c: fix copy_bits to be able to copy more than 64 bits

This commit is contained in:
Moritz Bunkus 2018-11-21 16:31:59 +01:00
parent 175f043ed1
commit 38c046eda3
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85

View File

@ -53,8 +53,14 @@ public:
}
inline uint64_t copy_bits(std::size_t n, reader_c &src) {
uint64_t value = src.get_bits(n);
put_bits(n, value);
uint64_t value{};
while (n) {
auto to_copy = std::min<std::size_t>(n, 64);
n -= to_copy;
value = src.get_bits(to_copy);
put_bits(to_copy, value);
}
return value;
}