diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-08-03 17:22:03 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-08-03 17:22:03 -0700 |
commit | 946dcf4a5d9e35046eb4c2bd4c31e2d4633199e0 (patch) | |
tree | dcf70b28e7b9d1c1b3e0eddc8477eef15b8b4e01 /src/upb_parse.h | |
parent | b07b1165d30b9f23ed418505d7a4f6ecc3664794 (diff) |
Fix tests (and src) such that all tests pass again.
Diffstat (limited to 'src/upb_parse.h')
-rw-r--r-- | src/upb_parse.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/upb_parse.h b/src/upb_parse.h index e727c11..f0ec5e2 100644 --- a/src/upb_parse.h +++ b/src/upb_parse.h @@ -208,6 +208,38 @@ INLINE upb_status_t upb_get_f_uint64_t(uint8_t *buf, uint8_t *end, return UPB_STATUS_OK; } +INLINE upb_status_t upb_skip_v_uint64_t(uint8_t *buf, uint8_t *end, + uint8_t **outbuf) +{ + uint8_t *const maxend = buf + 10; + uint8_t last = 0x80; + for(; buf < (uint8_t*)end && (last & 0x80); buf++) + last = *buf; + if(buf >= end && buf <= maxend && (last & 0x80)) return UPB_STATUS_NEED_MORE_DATA; + if(buf > maxend) return UPB_ERROR_UNTERMINATED_VARINT; + *outbuf = buf; + return UPB_STATUS_OK; +} + +INLINE upb_status_t upb_skip_f_uint32_t(uint8_t *buf, uint8_t *end, uint8_t + **outbuf) +{ + uint8_t *uint32_end = buf + sizeof(uint32_t); + if(uint32_end > end) return UPB_STATUS_NEED_MORE_DATA; + *outbuf = uint32_end; + return UPB_STATUS_OK; +} + +INLINE upb_status_t upb_skip_f_uint64_t(uint8_t *buf, uint8_t *end, uint8_t + **outbuf) +{ + uint8_t *uint64_end = buf + sizeof(uint64_t); + if(uint64_end > end) return UPB_STATUS_NEED_MORE_DATA; + *outbuf = uint64_end; + return UPB_STATUS_OK; +} + + /* Functions to read .proto values. *******************************************/ /* These functions read the appropriate wire value for a given .proto type |