summaryrefslogtreecommitdiffstats
path: root/pb_encode.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@npb.mail.kapsi.fi>2011-08-23 16:16:33 +0000
committerPetteri Aimonen <jpa@npb.mail.kapsi.fi>2011-08-23 16:16:33 +0000
commit64ac18c8848d3071a16065c84fca3b5e7210ce95 (patch)
treeaf3f7a5d759e51ac6ada8d95ea6e946709fb6bab /pb_encode.c
parent9966a8c9b680ada47b6bd5fe96405c0abaf773e4 (diff)
Changed autogenerated file naming from foo.c to foo.pb.c
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@965 e3a754e5-d11d-0410-8d38-ebb782a927b9
Diffstat (limited to 'pb_encode.c')
-rw-r--r--pb_encode.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/pb_encode.c b/pb_encode.c
index 2a4d8e1..d333cfd 100644
--- a/pb_encode.c
+++ b/pb_encode.c
@@ -67,6 +67,10 @@ bool checkreturn pb_write(pb_ostream_t *stream, const uint8_t *buf, size_t count
/* Main encoding stuff */
+/* Callbacks don't need this function because they usually know the data type
+ * without examining the field structure.
+ * Therefore it is static for now.
+ */
static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *field,
const void *pData, size_t count, pb_encoder_t func)
{
@@ -74,6 +78,9 @@ static bool checkreturn encode_array(pb_ostream_t *stream, const pb_field_t *fie
const void *p;
size_t size;
+ if (count == 0)
+ return true;
+
if (PB_LTYPE(field->type) < PB_LTYPE_LAST_PACKABLE)
{
if (!pb_encode_tag(stream, PB_WT_STRING, field->tag))