On Oct 20, 2010, at 2:13 , Kenton Varda wrote:
But you are actually writing a varint32, which can be anywhere between 1 and 5 bytes depending on the value.

Use CodedOutputStream::Varint32Size() to compute the number of bytes needed to encode a particular value.

This has the advantage that you can allocate a buffer of exactly the right size, rather than adding 100 as an estimate. However, you can also find the final size after all the writes with CodedOutputStream::ByteCount()

You should not need to do any byte swapping if you are serializing and deserializing integers using the protobuf API: it handles any required byte swapping for you.

Evan

--
Evan Jones
http://evanjones.ca/

--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to