aboutsummaryrefslogtreecommitdiffstats
path: root/pb_encode.c
diff options
context:
space:
mode:
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 2a4d8e11..d333cfd5 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))