diff options
author | Petteri Aimonen <jpa@github.mail.kapsi.fi> | 2016-10-11 08:12:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-11 08:12:38 +0300 |
commit | 599939a85dce96c78c357341b731ccc173885d5b (patch) | |
tree | 471ada847abce2a79ad4932daa9f07c382573a3d | |
parent | fe0aca04cbc41327144813ca54ea37aafb866d25 (diff) | |
parent | be75cf4d6002937f7767054ac5e540e6640d7628 (diff) |
Merge pull request #218 from berni155/master
Fix typo in encoding
-rw-r--r-- | pb_encode.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pb_encode.c b/pb_encode.c index 4f57fa5..b0a736a 100644 --- a/pb_encode.c +++ b/pb_encode.c @@ -214,15 +214,18 @@ static bool checkreturn encode_basic_field(pb_ostream_t *stream, { /* In proto3 there are optional fields but no has_ flag, do not encode this fields * when value is default or empty. */ - if(PB_LTYPE(field->type) == PB_LTYPE_BYTES){ + if(PB_LTYPE(field->type) == PB_LTYPE_BYTES) + { const pb_bytes_array_t *bytes = (const pb_bytes_array_t*)pData; if(bytes->size == 0) implicit_has = false; + } else if ((PB_LTYPE(field->type) == PB_LTYPE_STRING && *(const char*)pData == '\0') || (field->data_size == sizeof(uint_least8_t) && *(const uint_least8_t*)pData == 0) || (field->data_size == sizeof(uint_least16_t) && *(const uint_least16_t*)pData == 0) || (field->data_size == sizeof(uint32_t) && *(const uint_least32_t*)pData == 0) || (field->data_size == sizeof(uint64_t) && *(const uint_least64_t*)pData == 0)) + { implicit_has = false; } pSize = &implicit_has; |