mirror of
https://github.com/transmission/transmission
synced 2024-12-27 01:57:52 +00:00
chore: add more descriptive assertion in bitfield (#2748)
Related to #2727
This commit is contained in:
parent
7a227917ff
commit
1bafbd18ac
2 changed files with 8 additions and 2 deletions
|
@ -218,7 +218,12 @@ void tr_bitfield::freeArray()
|
|||
|
||||
void tr_bitfield::setTrueCount(size_t n)
|
||||
{
|
||||
TR_ASSERT(bit_count_ == 0 || n <= bit_count_);
|
||||
TR_ASSERT_MSG(
|
||||
bit_count_ == 0 || n <= bit_count_,
|
||||
"bit_count_:%zu, n:%zu, std::size(flags_):%zu",
|
||||
bit_count_,
|
||||
n,
|
||||
size_t(std::size(flags_)));
|
||||
|
||||
true_count_ = n;
|
||||
have_all_hint_ = n == bit_count_;
|
||||
|
@ -285,7 +290,7 @@ void tr_bitfield::setHasAll()
|
|||
|
||||
void tr_bitfield::setRaw(uint8_t const* raw, size_t byte_count)
|
||||
{
|
||||
flags_ = std::vector<uint8_t>(raw, raw + byte_count);
|
||||
flags_.assign(raw, raw + byte_count);
|
||||
|
||||
// ensure any excess bits at the end of the array are set to '0'.
|
||||
if (byte_count == getBytesNeeded(bit_count_))
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#endif
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue