aboutsummaryrefslogtreecommitdiffstats
path: root/pb_decode.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@github.mail.kapsi.fi>2016-08-05 07:38:53 +0300
committerGitHub <noreply@github.com>2016-08-05 07:38:53 +0300
commit68a86e96481e6bea987df8de47027847b30c325b (patch)
treeb96eaefeaeaacd123e8d7e2f033dda3ba1698681 /pb_decode.c
parent0198210f2cc349e7bc5199e8db7f4afc8208d843 (diff)
parent62afd54964528c1fbd5ab802134f7e9ad912d904 (diff)
Merge pull request #211 from tmroeder/feat-inline-bytes
Add inline allocation of bytes fields
Diffstat (limited to 'pb_decode.c')
-rw-r--r--pb_decode.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/pb_decode.c b/pb_decode.c
index 78911e7b..7a4e29a8 100644
--- a/pb_decode.c
+++ b/pb_decode.c
@@ -65,7 +65,8 @@ static const pb_decoder_t PB_DECODERS[PB_LTYPES_COUNT] = {
&pb_dec_bytes,
&pb_dec_string,
&pb_dec_submessage,
- NULL /* extensions */
+ NULL, /* extensions */
+ &pb_dec_bytes /* PB_LTYPE_FIXED_LENGTH_BYTES */
};
/*******************************
@@ -1272,6 +1273,12 @@ static bool checkreturn pb_dec_bytes(pb_istream_t *stream, const pb_field_t *fie
}
else
{
+ if (PB_LTYPE(field->type) == PB_LTYPE_FIXED_LENGTH_BYTES) {
+ if (size != field->data_size)
+ PB_RETURN_ERROR(stream, "incorrect inline bytes size");
+ return pb_read(stream, (pb_byte_t*)dest, field->data_size);
+ }
+
if (alloc_size > field->data_size)
PB_RETURN_ERROR(stream, "bytes overflow");
bdest = (pb_bytes_array_t*)dest;