Revert "Change the substream implementation in pb_decode."

This reverts commit dc2da0edc5.

Add pb_close_string_substream() for copying back the state.
This makes adding error messages easier in the future, as also
them need to be propagated back from the substream.
This commit is contained in:
Petteri Aimonen
2012-08-24 20:43:21 +03:00
parent 2941e90e04
commit 9383f305dc
3 changed files with 29 additions and 14 deletions

View File

@@ -45,10 +45,13 @@ 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_istream_t substream;
bool status;
if (!pb_make_string_substream(stream, &substream))
return false;
return pb_decode(&substream, fields, dest_struct);
status = pb_decode(&substream, fields, dest_struct);
pb_close_string_substream(stream, &substream);
return status;
}
int main()