aboutsummaryrefslogtreecommitdiffstats
path: root/pb_decode.c
AgeCommit message (Collapse)AuthorFilesLines
2013-10-29Declare static functions before use.Petteri Aimonen1-12/+31
For compliance with MISRA C rules (issue 91).
2013-10-29Cleanup of comments.Petteri Aimonen1-7/+8
2013-10-29Rename some internal functions to have unique namesPetteri Aimonen1-2/+2
2013-07-17Extension support implemented for decoder.Petteri Aimonen1-2/+94
Testing is still needed. Also only 'optional' extension fields are supported now, 'repeated' fields are not yet supported.
2013-07-16Check for empty message type before incrementing required_field_index.Kent Ryhorchuk1-3/+3
If you have a message that defined as empty, but attempt to decode a message that has one or more unknown fields then pb_decode fails. The method used to count the number of required fields counts 1 required field because the default type of PB_LAST_FIELD is PB_HTYPE_REQUIRED.
2013-07-06Add pb_decode_delimited and pb_encode_delimited wrapper functions.Petteri Aimonen1-0/+13
Update issue 74 Status: FixedInGit
2013-04-14Fix bug with empty strings in repeated string callbacks.Petteri Aimonen1-2/+2
Fix suggested by Henrik Carlgren. Added also unit test for the bug. Update issue 73 Status: FixedInGit
2013-04-08Avoid maybe-uninitialized warningPetteri Aimonen1-4/+6
Patch from dch.
2013-04-02Change the callback function to use void**.Petteri Aimonen1-2/+8
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
2013-03-09Add PB_SYSTEM_HEADER compile time option.Petteri Aimonen1-1/+0
This allows replacing the C99 standard include file names with a single system-specific file. It should provide all the necessary system functions (typedefs, memset, memcpy, strlen). Update issue 62 Status: FixedInGit
2013-03-09Rename pb_field_iterator_t field 'current' to 'pos'.Petteri Aimonen1-38/+38
This avoids a name clash when compiling as Linux kernel module. Update issue 60 Status: FixedInGit
2013-03-09Fix additional bug with empty message types.Petteri Aimonen1-0/+3
pb_field_next() would access past the fields array.
2013-03-09Fix bug with decoding empty message types. Add test for the same.Petteri Aimonen1-1/+1
Note: the bug only applies to empty message types. Empty messages of non-empty message types are not affected. Update issue 65 Status: FixedInGit
2013-02-20Separate PB_HTYPE to PB_ATYPE and PB_HTYPE.Petteri Aimonen1-66/+94
Also clean up the logic so that it is easier to implement more allocation types in the future. Update issue 53 Status: FixedInGit
2013-02-20Rename PB_HTYPE_ARRAY -> PB_HTYPE_REPEATED.Petteri Aimonen1-4/+4
This is a more logical name in parallel with PB_HTYPE_REQUIRED and PB_HTYPE_OPTIONAL. Warning: This breaks backwards-compatibility of generated .pb.c files. You will have to regenerate the files and recompile.
2013-02-07Fix error message bugs with packed arrays.Petteri Aimonen1-3/+9
Error messages were not propagated correctly with PB_HTYPE_ARRAY. Error status (boolean return value) was correct. Update issue 56 Status: FixedInGit
2013-02-07Fix compiler warning on MSVC (issue #57)Petteri Aimonen1-1/+1
2013-02-06Use unsigned datatypes where appropriate.Petteri Aimonen1-9/+9
2013-02-06Improve the pb_decode_varint implementations.Petteri Aimonen1-18/+40
Results for ARM: -4% execution time, +1% code size
2013-02-06Avoid unnecessary looping in required fields check.Petteri Aimonen1-7/+26
Results for ARM: -6% execution time, -1% code size
2013-02-06Add compile-time option PB_BUFFER_ONLY.Petteri Aimonen1-0/+11
This allows slight optimizations if only memory buffer support (as opposed to stream callbacks) is wanted. On ARM difference is -12% execution time, -4% code size when enabled.
2013-02-05Make pb_decode_varint32 a separate implementation.Petteri Aimonen1-4/+14
This avoids doing 64-bit arithmetic for 32-bit varint decodings. It does increase the code size somewhat. Results for ARM Cortex-M3: -10% execution time, +1% code size, -2% ram usage.
2013-02-05Performance improvement: replace memcpy with loop.Petteri Aimonen1-2/+5
In the pb_istream_from_buffer and pb_ostream_from_buffer, memcpy was used to transfer values to the buffer. For the common case of count = 1-10 bytes, a simple loop is faster.
2013-01-16Oops, typoed #ifdef; again fixing previous commit.Petteri Aimonen1-1/+1
2013-01-16Put previous commit (issue 52) inside #ifndefPetteri Aimonen1-0/+3
2013-01-16Fix bug with error messages.Petteri Aimonen1-0/+1
Update issue 52 Status: FixedInGit
2012-11-27Complete initialization of pb_istream_t.Jens Steinhauser1-0/+3
Because PB_RETURN_ERROR checks if the 'errmsg' member is NULL before assigning to it, error messages would get lost.
2012-10-18Remove the "buf = NULL" => skip requirement from pb_istream_t callbacks.Petteri Aimonen1-11/+26
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
2012-09-03Enable -Wconversion for core and fix the warnings.Petteri Aimonen1-4/+4
This should help avoid issue 33 in the future.
2012-09-03Fix build warnings on MS compilersdch1-4/+4
Update issue 33 Status: FixedInGit
2012-08-26Fix warnings with -Wcast-qual. Add test for C++ compile.Petteri Aimonen1-1/+8
Update issue 27 Status: FixedInGit
2012-08-26Add pb_decode_noinit and use it from pb_dec_submessage.Petteri Aimonen1-4/+8
This avoids double initialization when decoding nested submessages. Fixes an issue with submessage arrays that was present in previous version of this patch. Update issue 28 Status: FixedInGit
2012-08-26Revert "Add pb_decode_noinit and use it from pb_dec_submessage."Petteri Aimonen1-8/+4
The patch breaks default values inside submessage arrays (I think). Have to add test cases and check back. This reverts commit f1d7640fe1be0f150f604c72108ea516222c2505.
2012-08-26Add pb_decode_noinit and use it from pb_dec_submessage.Petteri Aimonen1-4/+8
This avoids double initialization when decoding nested submessages. Update issue 28 Status: FixedInGit
2012-08-24Implement error messages in the decoder side.Petteri Aimonen1-15/+15
Update issue 7 Status: Started
2012-08-24Revert "Change the substream implementation in pb_decode."Petteri Aimonen1-13/+20
This reverts commit dc2da0edc568b29361479fb7405c96b1a13442cf. 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.
2012-08-24Reorganize the field decoder interface.Petteri Aimonen1-55/+82
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
2012-08-24Change the substream implementation in pb_decode.Petteri Aimonen1-16/+13
This makes it unnecessary to copy back the state, and also relaxes the requirements on callbacks (bytes_left will always be valid). It decreases code size by a few bytes, but may be just slightly slower.
2012-08-16Fix casting issuesStan Hu1-2/+2
2012-08-09Declare warn_unused_result only on GCC >= 3.4.0.Petteri Aimonen1-5/+5
Thanks to cea.max.simoes for bug report & fix. Update issue 25 Status: FixedInGit
2012-07-31Fix bug in decoder with packed arrays.Petteri Aimonen1-1/+4
Update issue 23 Status: FixedInGit
2012-07-19Additional unsigned vs. signed fix for tagPetteri Aimonen1-1/+1
2012-07-18Fix an unsigned vs. signed warning on some compiler.Petteri Aimonen1-2/+2
2012-07-18Fixed a few compiler warnings, added check.Petteri Aimonen1-1/+1
Main code is now compiled (for tests) with -pedantic -Wextra. The test programs are not as strictly bound, but this should improve the chances that atleast the core library compiles with most compilers without warnings.
2012-06-30Improve the detection of missing required fields.Petteri Aimonen1-15/+25
Now the limit of tracked fields is configurable at compile-time using PB_MAX_REQUIRED_FIELDS. Added related test and updated documentation. Fixes issue #18.
2012-06-16Added new functions to public interface in pb_decode.h.Petteri Aimonen1-18/+34
pb_decode_tag and pb_skip_field allow manually iterating the fields in a message.
2012-06-13Fix non-constant initializer errors with some compilers.Petteri Aimonen1-5/+14
Fixes issue #13. Thanks to Kevin Worth for reporting.
2012-04-18Fixing compiler warnings, mostly related to unused parameters.Petteri Aimonen1-2/+5
Thanks to David Hotham for the patch. Fixes issue 8.
2012-01-12Fixed issue 1 reported by Erik Rosen:Petteri Aimonen1-1/+3
The size of non-callback bytes-fields was miscalculated, which caused all following fields in a message to contain garbage. Previous commit contains a testcase for this. This fix changes the generated message description. If your protocol uses bytes-fields, you should regenerate *.pb.c.
2011-11-30Merged 0005-Handle-endianness-correctly.patch by Matt Kern.Petteri Aimonen1-5/+9
On big endian machines, pb_dec_fixed32 and pb_dec_fixed64 were incorrectly overwriting the result value even if reading failed. git-svn-id: https://svn.kapsi.fi/jpa/nanopb@1022 e3a754e5-d11d-0410-8d38-ebb782a927b9