Closed GoogleCodeExporter closed 9 years ago
Finding the encoded size is essentially the same operation as packing the data,
also in protobuf-c. Nanopb avoids the duplicated code by using pb_encode also
to calculate the size.
You can do it like this:
pb_ostream_t substream = {0};
pb_encode(&substream, fields, src_struct);
size = substream.bytes_written;
(http://koti.kapsi.fi/~jpa/nanopb/docs/concepts.html#output-streams "The
callback for output stream may be NULL, in which case the stream simply counts
the number of bytes written.")
Not sure if it is worth it to include a wrapper function to do that.
Original comment by Petteri.Aimonen
on 25 Jun 2012 at 4:58
Original comment by Petteri.Aimonen
on 30 Jun 2012 at 3:24
This issue was updated by revision b63e582bdb34.
Original comment by Petteri.Aimonen
on 5 Apr 2014 at 8:33
Fix released in nanopb-0.2.8
Original comment by Petteri.Aimonen
on 7 Apr 2014 at 5:51
Original issue reported on code.google.com by
feroz.af...@gmail.com
on 25 Jun 2012 at 4:47