aboutsummaryrefslogtreecommitdiffstats
path: root/pb_encode.c
diff options
context:
space:
mode:
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