summaryrefslogtreecommitdiffstats
path: root/pb_decode.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-01-04 11:36:42 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-01-04 12:02:15 +0200
commit50c67ecec4895f65ba684e4b46b4b70980a5be6a (patch)
tree650cea85ca6c544bc6c3026c670cea63057bf721 /pb_decode.c
parentb0d31468da7f644684be897cef5b0602ca10af0f (diff)
Add int_size option for generator.
This allows overriding the integer field types to e.g. uint8_t for saving RAM. Update issue 139 Status: FixedInGit
Diffstat (limited to 'pb_decode.c')
-rw-r--r--pb_decode.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/pb_decode.c b/pb_decode.c
index 367f073b..b5ec1ef0 100644
--- a/pb_decode.c
+++ b/pb_decode.c
@@ -1095,6 +1095,8 @@ static bool checkreturn pb_dec_uvarint(pb_istream_t *stream, const pb_field_t *f
switch (field->data_size)
{
+ case 1: *(uint8_t*)dest = (uint8_t)value; break;
+ case 2: *(uint16_t*)dest = (uint16_t)value; break;
case 4: *(uint32_t*)dest = (uint32_t)value; break;
case 8: *(uint64_t*)dest = value; break;
default: PB_RETURN_ERROR(stream, "invalid data_size");
@@ -1111,6 +1113,8 @@ static bool checkreturn pb_dec_svarint(pb_istream_t *stream, const pb_field_t *f
switch (field->data_size)
{
+ case 1: *(int8_t*)dest = (int8_t)value; break;
+ case 2: *(int16_t*)dest = (int16_t)value; break;
case 4: *(int32_t*)dest = (int32_t)value; break;
case 8: *(int64_t*)dest = value; break;
default: PB_RETURN_ERROR(stream, "invalid data_size");