From 7f53c3f7484679c1e38607f59542d43be1387650 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Wed, 17 Aug 2011 19:03:06 +0000 Subject: Example git-svn-id: https://svn.kapsi.fi/jpa/nanopb@957 e3a754e5-d11d-0410-8d38-ebb782a927b9 --- pb_encode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'pb_encode.c') diff --git a/pb_encode.c b/pb_encode.c index 188d768d..2e740347 100644 --- a/pb_encode.c +++ b/pb_encode.c @@ -130,7 +130,10 @@ bool pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_ { pData = (const char*)pData + prev_size + field->data_offset; pSize = (const char*)pData + field->size_offset; - prev_size = field->data_size * field->array_size; + + prev_size = field->data_size; + if (PB_HTYPE(field->type) == PB_HTYPE_ARRAY) + prev_size *= field->array_size; pb_encoder_t func = PB_ENCODERS[PB_LTYPE(field->type)]; @@ -339,7 +342,7 @@ bool pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field, const void substream.max_size = size; substream.bytes_written = 0; - status = pb_encode(stream, (pb_field_t*)field->ptr, src); + status = pb_encode(&substream, (pb_field_t*)field->ptr, src); stream->bytes_written += substream.bytes_written; -- cgit 1.2.3-korg