summaryrefslogtreecommitdiff
path: root/upb/pb
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2015-08-19 15:49:29 -0700
committerJosh Haberman <jhaberman@gmail.com>2015-08-19 15:49:29 -0700
commit1e870951d7707d45fa7104658a4dde177d9fb62e (patch)
treea307fbb9bf6dbd7930be74ff481631486dc3b494 /upb/pb
parent146a9c22efac6cb746ef4024144f28af891dd2b4 (diff)
Refer to a shared definition for max buffered bytes.
Diffstat (limited to 'upb/pb')
-rw-r--r--upb/pb/decoder.h7
-rw-r--r--upb/pb/decoder.int.h7
2 files changed, 9 insertions, 5 deletions
diff --git a/upb/pb/decoder.h b/upb/pb/decoder.h
index 65316b4..8172a99 100644
--- a/upb/pb/decoder.h
+++ b/upb/pb/decoder.h
@@ -36,6 +36,13 @@ UPB_DECLARE_TYPE(upb::pb::DecoderMethodOptions, upb_pbdecodermethodopts)
UPB_DECLARE_DERIVED_TYPE(upb::pb::DecoderMethod, upb::RefCounted,
upb_pbdecodermethod, upb_refcounted)
+/* The maximum number of bytes we are required to buffer internally between
+ * calls to the decoder. The value is 14: a 5 byte unknown tag plus ten-byte
+ * varint, less one because we are buffering an incomplete value.
+ *
+ * Should only be used by unit tests. */
+#define UPB_DECODER_MAX_RESIDUAL_BYTES 14
+
#ifdef __cplusplus
/* The parameters one uses to construct a DecoderMethod.
diff --git a/upb/pb/decoder.int.h b/upb/pb/decoder.int.h
index b7e462b..f2bf242 100644
--- a/upb/pb/decoder.int.h
+++ b/upb/pb/decoder.int.h
@@ -218,11 +218,8 @@ struct upb_pbdecoder {
/* Overall stream offset of "buf." */
uint64_t bufstart_ofs;
- /* Buffer for residual bytes not parsed from the previous buffer.
- * The maximum number of residual bytes we require is 12; a five-byte
- * unknown tag plus a ten-byte value, less one because the value
- * is only a partial value. */
- char residual[14];
+ /* Buffer for residual bytes not parsed from the previous buffer. */
+ char residual[UPB_DECODER_MAX_RESIDUAL_BYTES];
char *residual_end;
/* Bytes of data that should be discarded from the input beore we start
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback