aboutsummaryrefslogtreecommitdiffstats
path: root/pb_encode.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-12-26 18:23:36 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-12-26 18:23:36 +0200
commit418f7d88b3f58603fe03d0060b8aaba905ca56c8 (patch)
treeea85e1ecbeaab94a28e60141577faa27b0173011 /pb_encode.c
parent980f899dd5ca1b4201536cdb56a723ba7777d82c (diff)
Add support for POINTER type in extensions
Diffstat (limited to 'pb_encode.c')
-rw-r--r--pb_encode.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/pb_encode.c b/pb_encode.c
index cdd78955..5318361e 100644
--- a/pb_encode.c
+++ b/pb_encode.c
@@ -302,7 +302,18 @@ static bool checkreturn default_extension_encoder(pb_ostream_t *stream,
const pb_extension_t *extension)
{
const pb_field_t *field = (const pb_field_t*)extension->type->arg;
- return encode_field(stream, field, extension->dest);
+
+ if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
+ {
+ /* For pointer extensions, the pointer is stored directly
+ * in the extension structure. This avoids having an extra
+ * indirection. */
+ return encode_field(stream, field, &extension->dest);
+ }
+ else
+ {
+ return encode_field(stream, field, extension->dest);
+ }
}
/* Walk through all the registered extensions and give them a chance