summaryrefslogtreecommitdiffstats
path: root/pb_encode.c
AgeCommit message (Collapse)AuthorFilesLines
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