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 /example | |
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 'example')
-rw-r--r-- | example/common.c | 9 |
1 files changed, 0 insertions, 9 deletions
diff --git a/example/common.c b/example/common.c index b27ccae2..04a5aa85 100644 --- a/example/common.c +++ b/example/common.c @@ -19,15 +19,6 @@ static bool read_callback(pb_istream_t *stream, uint8_t *buf, size_t count) int fd = (intptr_t)stream->state; int result; - if (buf == NULL) - { - /* Well, this is a really inefficient way to skip input. */ - /* It is only used when there are unknown fields. */ - char dummy; - while (count-- && recv(fd, &dummy, 1, 0) == 1); - return count == 0; - } - result = recv(fd, buf, count, MSG_WAITALL); if (result == 0) |