| 606 | |
| 607 | |
| 608 | bool cByteBuffer::WriteVarInt(UInt32 a_Value) |
| 609 | { |
| 610 | CHECK_THREAD; |
| 611 | CheckValid(); |
| 612 | |
| 613 | // A 32-bit integer can be encoded by at most 5 bytes: |
| 614 | unsigned char b[5]; |
| 615 | int idx = 0; |
| 616 | do |
| 617 | { |
| 618 | b[idx] = (a_Value & 0x7f) | ((a_Value > 0x7f) ? 0x80 : 0x00); |
| 619 | a_Value = a_Value >> 7; |
| 620 | idx++; |
| 621 | } while (a_Value > 0); |
| 622 | |
| 623 | return WriteBuf(b, idx); |
| 624 | } |
| 625 | |
| 626 | |
| 627 |
no outgoing calls