summaryrefslogtreecommitdiffstats
path: root/example_unions/decode.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-08-24 20:23:25 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-08-24 20:23:25 +0300
commit2941e90e041b0d7872a4ea458e77dcc787ca6ff2 (patch)
treeca2f8b83d059e4ac5569413498aa27230ba2083c /example_unions/decode.c
parentdc2da0edc568b29361479fb7405c96b1a13442cf (diff)
Reorganize the field decoder interface.
This makes the field decoding functions more intuitive to use. The old interface is still present if you specify NANOPB_INTERNALS. Update issue 2 Status: FixedInGit
Diffstat (limited to 'example_unions/decode.c')
-rw-r--r--example_unions/decode.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/example_unions/decode.c b/example_unions/decode.c
index edd568cb..a7cc7814 100644
--- a/example_unions/decode.c
+++ b/example_unions/decode.c
@@ -44,10 +44,11 @@ const pb_field_t* decode_unionmessage_type(pb_istream_t *stream)
bool decode_unionmessage_contents(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct)
{
- pb_field_t field = {}; /* NB: Could get rid of this wrapper by fixing issue #2. */
- field.ptr = fields;
+ pb_istream_t substream;
+ if (!pb_make_string_substream(stream, &substream))
+ return false;
- return pb_dec_submessage(stream, &field, dest_struct);
+ return pb_decode(&substream, fields, dest_struct);
}
int main()