summaryrefslogtreecommitdiffstats
path: root/pb_encode.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@npb.mail.kapsi.fi>2011-08-14 20:11:05 +0000
committerPetteri Aimonen <jpa@npb.mail.kapsi.fi>2011-08-14 20:11:05 +0000
commit842d52633d650286ce62490362f8dfa356e17800 (patch)
tree6597bc4dc16ac13d129901fd42e76fb776e86a7d /pb_encode.c
parent6dfba365b00175eae7e8b83aaf5d29ce190fd9eb (diff)
More documentation, small improvements
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@955 e3a754e5-d11d-0410-8d38-ebb782a927b9
Diffstat (limited to 'pb_encode.c')
-rw-r--r--pb_encode.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/pb_encode.c b/pb_encode.c
index 19a531cf..188d768d 100644
--- a/pb_encode.c
+++ b/pb_encode.c
@@ -124,11 +124,13 @@ bool pb_encode(pb_ostream_t *stream, const pb_field_t fields[], const void *src_
const pb_field_t *field = fields;
const void *pData = src_struct;
const void *pSize;
+ size_t prev_size = 0;
while (field->tag != 0)
{
- pData = (const char*)pData + field->data_offset;
+ pData = (const char*)pData + prev_size + field->data_offset;
pSize = (const char*)pData + field->size_offset;
+ prev_size = field->data_size * field->array_size;
pb_encoder_t func = PB_ENCODERS[PB_LTYPE(field->type)];