diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-04-02 19:55:21 +0300 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-04-02 19:55:21 +0300 |
commit | 214b0eae8aa011fa8b3e8a3dcc784f8d423aeffb (patch) | |
tree | 8cdebc1ab067bca01d47eefcc9dcf43ce50048db /tests/encode_unittests.c | |
parent | 6f3740f74ed48daf51908676b203f1889455c17d (diff) |
Change the callback function to use void**.
NOTE: This change breaks backwards-compatibility by default.
If you have old callback functions, you can define PB_OLD_CALLBACK_STYLE
to retain the old behaviour.
If you want to convert your old callbacks to new signature, you need
to do the following:
1) Change decode callback argument to void **arg
and encode callback argument to void * const *arg.
2) Change any reference to arg into *arg.
The rationale for making the new behaviour the default is that it
simplifies the common case of "allocate some memory in decode callback".
Update issue 69
Status: FixedInGit
Diffstat (limited to 'tests/encode_unittests.c')
-rw-r--r-- | tests/encode_unittests.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/encode_unittests.c b/tests/encode_unittests.c index 9cdbc66e..3078998e 100644 --- a/tests/encode_unittests.c +++ b/tests/encode_unittests.c @@ -17,7 +17,7 @@ bool streamcallback(pb_ostream_t *stream, const uint8_t *buf, size_t count) return true; } -bool fieldcallback(pb_ostream_t *stream, const pb_field_t *field, const void *arg) +bool fieldcallback(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) { int value = 0x55; if (!pb_encode_tag_for_field(stream, field)) @@ -25,7 +25,7 @@ bool fieldcallback(pb_ostream_t *stream, const pb_field_t *field, const void *ar return pb_encode_varint(stream, value); } -bool crazyfieldcallback(pb_ostream_t *stream, const pb_field_t *field, const void *arg) +bool crazyfieldcallback(pb_ostream_t *stream, const pb_field_t *field, void * const *arg) { /* This callback writes different amount of data the second time. */ uint32_t *state = (uint32_t*)arg; |