Changeset 14646


Ignore:
Timestamp:
Dec 31, 2015, 5:22:42 AM (5 years ago)
Author:
mikedld
Message:

Loosen bitfield assertions to account for unknown bit counts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bitfield.c

    r14637 r14646  
    255255tr_bitfieldSetTrueCount (tr_bitfield * b, size_t n)
    256256{
    257   assert (n <= b->bit_count);
     257  assert (b->bit_count == 0 || n <= b->bit_count);
    258258
    259259  b->true_count = n;
     
    274274tr_bitfieldIncTrueCount (tr_bitfield * b, size_t i)
    275275{
    276   assert (i <= b->bit_count);
    277   assert (b->true_count <= b->bit_count - i);
     276  assert (b->bit_count == 0 || i <= b->bit_count);
     277  assert (b->bit_count == 0 || b->true_count <= b->bit_count - i);
    278278
    279279  tr_bitfieldSetTrueCount (b, b->true_count + i);
     
    283283tr_bitfieldDecTrueCount (tr_bitfield * b, size_t i)
    284284{
    285   assert (i <= b->bit_count);
    286   assert (b->true_count >= i);
     285  assert (b->bit_count == 0 || i <= b->bit_count);
     286  assert (b->bit_count == 0 || b->true_count >= i);
    287287
    288288  tr_bitfieldSetTrueCount (b, b->true_count - i);
Note: See TracChangeset for help on using the changeset viewer.