putVarint method
Writes an unsigned integer as a base-128 varint. The number is written, 7 bits at a time, from the least significant to the most significant 7 bits. Each byte, except the last, has the MSB set.
@param l The int or long value to be written @return Number of bytes written @see protocol buffers encoding
Implementation
int putVarint(int num) {
int rest = num;
int bytes = 0;
int b;
do {
b = _parseByte(rest);
if (b != rest) {
b |= 0x80;
}
putByte(b);
rest >>>= 7;
bytes++;
} while (rest != 0);
return bytes;
}