Move the declarations of _pb_ostream_t and _pb_istream_t before first use.
[apps/agl-service-can-low-level.git] / pb_encode.c
index f3c62a1..d6ba7e3 100644 (file)
@@ -28,7 +28,8 @@ static const pb_encoder_t PB_ENCODERS[PB_LTYPES_COUNT] = {
     
     &pb_enc_bytes,
     &pb_enc_string,
-    &pb_enc_submessage
+    &pb_enc_submessage,
+    NULL /* extensions */
 };
 
 /* pb_ostream_t implementation */
@@ -160,9 +161,14 @@ static bool checkreturn encode_static_field(pb_ostream_t *stream,
 {
     pb_encoder_t func;
     const void *pSize;
+    bool dummy = true;
     
     func = PB_ENCODERS[PB_LTYPE(field->type)];
-    pSize = (const char*)pData + field->size_offset;
+    
+    if (field->size_offset)
+        pSize = (const char*)pData + field->size_offset;
+    else
+        pSize = &dummy;
     
     switch (PB_HTYPE(field->type))
     {