aboutsummaryrefslogtreecommitdiffstats
path: root/pb_common.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-08-10 13:01:09 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-08-10 13:01:09 +0300
commit7edf250a627b56c43e44de546b73bf113d9dea59 (patch)
tree79b4c0f96a62d77664f01db144b25aa25217f974 /pb_common.c
parenta641e21b34aed824b6b919f7ab9937eaadf09473 (diff)
Switch pb_encode to use the common iterator logic in pb_common.c
Update issue 128 Status: FixedInGit
Diffstat (limited to 'pb_common.c')
-rw-r--r--pb_common.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/pb_common.c b/pb_common.c
index de217699..a9cade63 100644
--- a/pb_common.c
+++ b/pb_common.c
@@ -5,7 +5,7 @@
#include "pb_common.h"
-void pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct)
+bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *dest_struct)
{
iter->start = fields;
iter->pos = fields;
@@ -13,6 +13,8 @@ void pb_field_iter_begin(pb_field_iter_t *iter, const pb_field_t *fields, void *
iter->dest_struct = dest_struct;
iter->pData = (char*)dest_struct + iter->pos->data_offset;
iter->pSize = (char*)iter->pData + iter->pos->size_offset;
+
+ return (iter->pos->tag != 0);
}
bool pb_field_iter_next(pb_field_iter_t *iter)
@@ -31,7 +33,7 @@ bool pb_field_iter_next(pb_field_iter_t *iter)
if (iter->pos->tag == 0)
{
/* Wrapped back to beginning, reinitialize */
- pb_field_iter_begin(iter, iter->start, iter->dest_struct);
+ (void)pb_field_iter_begin(iter, iter->start, iter->dest_struct);
return false;
}
else