diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2012-10-18 19:45:28 +0300 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2012-10-18 19:45:28 +0300 |
commit | dcab39a41c0a403db38860c22426075e6ae9f25d (patch) | |
tree | 7f1824628371ec59353b0765a209e6e5518401f7 /pb_decode.h | |
parent | 900c8dd1252afe2b2474b852ae48dcb46e100505 (diff) |
Remove the "buf = NULL" => skip requirement from pb_istream_t callbacks.
Rationale: it's easy to implement the callback wrong. Doing so introduces
io errors when unknown fields are present in the input. If code is not
tested with unknown fields, these bugs can remain hidden for long time.
Added a special case for the memory buffer stream, where it gives a small
speed benefit.
Added testcase for skipping fields with test_decode2 implementation.
Update issue 37
Status: FixedInGit
Diffstat (limited to 'pb_decode.h')
-rw-r--r-- | pb_decode.h | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/pb_decode.h b/pb_decode.h index 483665e..2be9205 100644 --- a/pb_decode.h +++ b/pb_decode.h @@ -19,12 +19,10 @@ * Rules for callback: * 1) Return false on IO errors. This will cause decoding to abort. * - * 2) If buf is NULL, read but don't store bytes ("skip input"). - * - * 3) You can use state to store your own data (e.g. buffer pointer), + * 2) You can use state to store your own data (e.g. buffer pointer), * and rely on pb_read to verify that no-body reads past bytes_left. * - * 4) Your callback may be used with substreams, in which case bytes_left + * 3) Your callback may be used with substreams, in which case bytes_left * is different than from the main stream. Don't use bytes_left to compute * any pointers. */ |