- pb_callback_t *pCallback = (pb_callback_t*)iter->pData;
-
- if (pCallback->funcs.decode == NULL)
- return skip(stream, wire_type);
-
- if (wire_type == PB_WT_STRING)
- {
- pb_istream_t substream;
-
- if (!make_string_substream(stream, &substream))
- return false;
-
- while (substream.bytes_left)
- {
- if (!pCallback->funcs.decode(&substream, iter->current, pCallback->arg))
- return false;
- }
-
- stream->state = substream.state;
- return true;
- }
- else
- {
- /* Copy the single scalar value to stack.
- * This is required so that we can limit the stream length,
- * which in turn allows to use same callback for packed and
- * not-packed fields. */
- pb_istream_t substream;
- uint8_t buffer[10];
- size_t size = sizeof(buffer);
-
- if (!read_raw_value(stream, wire_type, buffer, &size))
- return false;
- substream = pb_istream_from_buffer(buffer, size);
-
- return pCallback->funcs.decode(&substream, iter->current, pCallback->arg);
- }
+ if (!pCallback->funcs.decode(&substream, iter->current, pCallback->arg))
+ PB_RETURN_ERROR(stream, "callback failed");