aboutsummaryrefslogtreecommitdiffstats
path: root/pb_encode.c
AgeCommit message (Collapse)AuthorFilesLines
2013-12-29Organize allocation logic in generator, add pb_bytes_ptr_t.Petteri Aimonen1-3/+3
Allocation decision is now made before the field data type is decided. This way the data type decisions can more cleanly account for the allocation type, i.e. FT_DEFAULT logic etc. Added pb_bytes_ptr_t for pointer-allocated bytes-fields. There is no point generating separate structs for these, as they would all be of the same type.
2013-12-29Const-correctness and small cleanup.Petteri Aimonen1-21/+25
2013-12-29Generating and encoding messages with dynamic allocaitonMartin Donath1-14/+53
2013-12-21Add PB_LTYPE_UVARINT to fix encoding of negative int32 values.Petteri Aimonen1-2/+21
Apparently int32 values that are negative must be cast into int64 first before being encoded. Because uint32 still needs to be cast to uint64, the cases for int32 and uint32 had to be separated. Update issue 97 Status: FixedInGit
2013-10-29Remove the NANOPB_INTERNALS functions from public API.Petteri Aimonen1-1/+7
These have been deprecated since nanopb-0.1.6 (some since 0.1.3). Equivalent functions with better interface are available in the API. Update issue 91 Status: FixedInGit
2013-10-29Declare static functions before use.Petteri Aimonen1-1/+12
For compliance with MISRA C rules (issue 91).
2013-10-29Cleanup of comments.Petteri Aimonen1-8/+19
2013-10-29Rename some internal functions to have unique namesPetteri Aimonen1-2/+2
2013-10-24Detect invalid sizes when encoding bytes fields.Petteri Aimonen1-1/+4
2013-10-20Check array max size when encoding.Petteri Aimonen1-0/+3
Update issue 90 Status: FixedInGit
2013-07-22Fix bugs in extension support when multiple extension fields are present.Petteri Aimonen1-1/+6
2013-07-17Extension support implemented for decoder.Petteri Aimonen1-1/+2
Testing is still needed. Also only 'optional' extension fields are supported now, 'repeated' fields are not yet supported.
2013-07-17Implement extension support for the encoderPetteri Aimonen1-21/+73
2013-07-06Add pb_decode_delimited and pb_encode_delimited wrapper functions.Petteri Aimonen1-0/+5
Update issue 74 Status: FixedInGit
2013-04-14Handle unterminated strings when encoding.Petteri Aimonen1-2/+10
If the null terminator is not present, string will be limited to the data size of the field. If you are still using the pb_enc_string (deprecated since 0.1.3) from callbacks, now would be an excellent time to stop. The pb_field_t for the callback will not contain proper data_size. Use pb_encode_string() instead. Update issue 68 Status: FixedInGit
2013-04-02Change the callback function to use void**.Petteri Aimonen1-1/+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-09Implement error message support for the encoder side.Petteri Aimonen1-14/+23
Update issue 7 Status: FixedInGit
2013-02-20Separate PB_HTYPE to PB_ATYPE and PB_HTYPE.Petteri Aimonen1-33/+64
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-2/+2
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-06Add compile-time option PB_BUFFER_ONLY.Petteri Aimonen1-1/+10
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-05Performance improvement: replace memcpy with loop.Petteri Aimonen1-1/+4
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.
2012-09-03Enable -Wconversion for core and fix the warnings.Petteri Aimonen1-5/+5
This should help avoid issue 33 in the future.
2012-09-02Clean up one (uint64_t) cast.Petteri Aimonen1-2/+2
2012-08-26Fix warnings with -Wcast-qual. Add test for C++ compile.Petteri Aimonen1-14/+14
Update issue 27 Status: FixedInGit
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-18Fixed a few compiler warnings, added check.Petteri Aimonen1-2/+2
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-07-05Apparently some compilers don't want to automatically cast size_t to uint64_t.Petteri Aimonen1-4/+4
2012-07-05Fix some typos in __BIG_ENDIAN__ codePetteri Aimonen1-2/+2
2012-06-13Fix non-constant initializer errors with some compilers.Petteri Aimonen1-3/+14
Fixes issue #13. Thanks to Kevin Worth for reporting.
2012-04-18Fixing compiler warnings, mostly related to unused parameters.Petteri Aimonen1-2/+6
Thanks to David Hotham for the patch. Fixes issue 8.
2012-03-01Refactoring the field encoder interface.Petteri Aimonen1-77/+93
Replaced the confusing pb_enc_* functions with new pb_encode_* functions that have a cleaner interface. Updated documentation. Got rid of the endian_copy stuff in pb_encode.c, instead using C casts to do it automatically. This makes the code safer and also reduces binary size by about 5%. Fixes Issue 6.
2011-12-30Fixed a bug related to submessage encoding into memory buffer.Petteri Aimonen1-0/+1
Stream state was not copied back from substream in pb_enc_submessage, which caused garbage output if the stream callback modified the state. Expanded tests to cover this problem. Thanks to Paweł Pery for debugging and reporting this problem. git-svn-id: https://svn.kapsi.fi/jpa/nanopb@1089 e3a754e5-d11d-0410-8d38-ebb782a927b9
2011-11-10Fix some compiler warnings in strict C89 modePetteri Aimonen1-3/+2
Contributed by Michael Poole. git-svn-id: https://svn.kapsi.fi/jpa/nanopb@1004 e3a754e5-d11d-0410-8d38-ebb782a927b9
2011-09-13Fixed a bunch of bugs related to callback fields.Petteri Aimonen1-14/+30
Most importantly, callback fields in submessages were being overwritten with garbage, causing segfaults. Additionally, converted PB_LTYPE_FIXED to PB_LTYPE_FIXED32 and PB_LTYPE_FIXED64. This makes the interface a bit easier to use, and in addition runs faster. git-svn-id: https://svn.kapsi.fi/jpa/nanopb@975 e3a754e5-d11d-0410-8d38-ebb782a927b9
2011-08-23More unittestsPetteri Aimonen1-1/+1
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@966 e3a754e5-d11d-0410-8d38-ebb782a927b9
2011-08-23Changed autogenerated file naming from foo.c to foo.pb.cPetteri Aimonen1-0/+7
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@965 e3a754e5-d11d-0410-8d38-ebb782a927b9
2011-08-23check return valuesPetteri Aimonen1-16/+25
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@961 e3a754e5-d11d-0410-8d38-ebb782a927b9
2011-08-17ExamplePetteri Aimonen1-2/+5
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@957 e3a754e5-d11d-0410-8d38-ebb782a927b9
2011-08-14More documentation, small improvementsPetteri Aimonen1-1/+3
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@955 e3a754e5-d11d-0410-8d38-ebb782a927b9
2011-08-11Documenting and improving stream behaviourPetteri Aimonen1-4/+22
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@954 e3a754e5-d11d-0410-8d38-ebb782a927b9
2011-08-10Unittests for encodePetteri Aimonen1-14/+19
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@952 e3a754e5-d11d-0410-8d38-ebb782a927b9
2011-08-04EncoderPetteri Aimonen1-0/+326
git-svn-id: https://svn.kapsi.fi/jpa/nanopb@951 e3a754e5-d11d-0410-8d38-ebb782a927b9