Change the API for pb_make_string_substream() to use less stack.

If your own application uses this function, you have to change
the old style:

    pb_istream_t substream;
    if (!pb_make_string_substream(stream, &substream))
        return false;
    .. do stuff with substream ..
    pb_close_string_substream(stream, &substream);

to the new style:

    size_t remaining;
    if (!pb_make_string_substream(stream, &remaining))
        return false;
    .. do stuff with stream ..
    pb_close_string_substream(stream, remaining);
This commit is contained in:
Petteri Aimonen
2013-11-14 19:16:49 +02:00
parent eff9e11150
commit cace53dfbd
2 changed files with 32 additions and 36 deletions

View File

@@ -128,8 +128,8 @@ bool pb_decode_fixed32(pb_istream_t *stream, void *dest);
bool pb_decode_fixed64(pb_istream_t *stream, void *dest);
/* Make a limited-length substream for reading a PB_WT_STRING field. */
bool pb_make_string_substream(pb_istream_t *stream, pb_istream_t *substream);
void pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream);
bool pb_make_string_substream(pb_istream_t *stream, size_t *remaining_length);
void pb_close_string_substream(pb_istream_t *stream, size_t remaining_length);
#ifdef __cplusplus
} /* extern "C" */