StabbyCutyou/buffstreams

Incorrect header length

luna-duclos opened this issue · 1 comments

Headers are encoded with Varint encoding, as per the spec for varint: https://developers.google.com/protocol-buffers/docs/encoding

Varint encoding uses the 8th bit of each byte as a more flag.
As such, only 7 bits per byte actually contain data.

This means that a 64 bit number now needs 80 bits to actually be encoded if the number is large enough.

Thanks for finding this. Although I could account for this by adjusting the calculation for the header size, I'm wondering if you know of a better approach for calculating this size not using Varint encoding?

I have gone through a few different approaches here and Varint seemed the most reliable, but I know there are some other approaches, wondering if you have any opinions on a better one?