Lines Matching defs:bytes
767 static size_t upb_roundup_pow2(size_t bytes) {
769 while (ret < bytes) {
775 static bool upb_encode_growbuffer(upb_encstate *e, size_t bytes) {
777 size_t new_size = upb_roundup_pow2(bytes + (e->limit - e->ptr));
792 /* Call to ensure that at least "bytes" bytes are available for writing at
793 * e->ptr. Returns false if the bytes could not be allocated. */
794 static bool upb_encode_reserve(upb_encstate *e, size_t bytes) {
795 CHK(UPB_LIKELY((size_t)(e->ptr - e->buf) >= bytes) ||
796 upb_encode_growbuffer(e, bytes));
798 e->ptr -= bytes;
802 /* Writes the given bytes to the buffer, handling reserve/advance. */
863 size_t bytes = arr->len * elem_size;
865 const char* ptr = data + bytes - elem_size;
874 return upb_put_bytes(e, data, bytes) && upb_put_varint(e, bytes);
1453 size_t bytes;
1458 bytes = upb_table_size(t) * sizeof(upb_tabent);
1459 if (bytes > 0) {
1460 t->entries = upb_malloc(a, bytes);
1462 memset(mutable_entries(t), 0, bytes);
1643 size_t bytes = upb_table_size(&t->t) * sizeof(upb_tabent);
1645 memset((char*)t->t.entries, 0, bytes);
2087 /* Mix 4 bytes at a time into the hash */
2104 /* Handle the last few bytes of the input array */
2112 * bytes are well-incorporated. */
2195 * Handle tail bytes */
2227 * Handle tail bytes */
5130 /* Strings/bytes are special-cased in maps. */
5598 size_t bytes = upb_msgdef_submsgfieldcount(md) * sizeof(*h->sub);
5599 h->sub = upb_calloc(arena, bytes);
6142 /* The "tag" instructions only have 8 bytes available for the jump target,
6439 /* No tag should be greater than 5 bytes. */
6945 ** sometimes requires keeping a few trailing bytes from the last buffer around
7035 * to our "decode" callback or some residual bytes from the previous buffer. */
7037 /* How many bytes can be safely read from d->ptr without reading past end-of-buf
7044 /* How many bytes are available before end-of-buffer. */
7054 /* How many bytes are available before the end of this delimited region. */
7107 /* Skips "bytes" bytes in the stream, which may be more than available. If we
7108 * skip more bytes than are available, we return a long read count to the caller
7109 * indicating how many bytes can be skipped over before passing actual data
7110 * again. Skipped bytes can pass a NULL buffer and the decoder guarantees they
7113 static int32_t skip(upb_pbdecoder *d, size_t bytes) {
7116 if (bytes > delim_remaining(d)) {
7119 } else if (bufleft(d) >= bytes) {
7121 advance(d, bytes);
7127 d->skip = bytes - curbufleft(d);
7175 /* We have residual bytes from the last buffer. */
7201 * bytes. If there are any unconsumed bytes, returns a short byte count. */
7205 /* Checkpoint was in residual buf; no user bytes were consumed. */
7221 * bytes in our residual buffer. This is necessary if we need more user
7222 * bytes to form a complete value, which might not be contiguous in the
7223 * user's buffers. Always consumes all user bytes. */
7226 * Save any unconsumed bytes (if any) to the residual buffer. */
7239 /* Checkpoint was in user buf; old residual bytes not needed. */
7255 /* Copies the next "bytes" bytes into "buf" and advances the stream.
7256 * Requires that this many bytes are available in the current buffer. */
7258 size_t bytes) {
7259 UPB_ASSERT(bytes <= curbufleft(d));
7260 memcpy(buf, d->ptr, bytes);
7261 advance(d, bytes);
7264 /* Slow path for getting the next "bytes" bytes, regardless of whether they are
7268 size_t bytes) {
7271 bytes -= avail;
7272 UPB_ASSERT(bytes > 0);
7276 if (curbufleft(d) >= bytes) {
7277 consumebytes(d, (char *)buf + avail, bytes);
7287 /* Gets the next "bytes" bytes, regardless of whether they are available in the
7291 size_t bytes) {
7292 if (curbufleft(d) >= bytes) {
7294 consumebytes(d, buf, bytes);
7297 return getbytes_slow(d, buf, bytes);
7302 size_t bytes) {
7306 size_t copy = UPB_MIN(bytes - ret, d->size_param);
7314 size_t bytes) {
7315 if (curbufleft(d) >= bytes) {
7316 memcpy(buf, d->ptr, bytes);
7317 return bytes;
7319 return peekbytes_slow(d, buf, bytes);
7450 size_t bytes = upb_value_size(expected);
7451 size_t read = peekbytes(d, &data, bytes);
7452 if (read == bytes && data == expected) {
7453 /* Advance past matched bytes. */
7457 } else if (read < bytes && memcmp(&data, &expected, read) == 0) {
7741 * consume bytes beyond data_end, which covers delim_end when non-NULL.
7993 ** varints, which means that we don't know how many bytes to reserve for the
8002 ** many bytes each length will take. When our guesses are wrong, use
8047 * We also use the concept of a "run", which is a range of encoded bytes that
8119 /* Call to ensure that at least "bytes" bytes are available for writing at
8120 * e->ptr. Returns false if the bytes could not be allocated. */
8121 static bool reserve(upb_pb_encoder *e, size_t bytes) {
8122 if ((size_t)(e->limit - e->ptr) < bytes) {
8125 size_t needed = bytes + (e->ptr - e->buf);
8149 /* Call when "bytes" bytes have been writte at e->ptr. The caller *must* have
8150 * previously called reserve() with at least this many bytes. */
8151 static void encoder_advance(upb_pb_encoder *e, size_t bytes) {
8152 UPB_ASSERT((size_t)(e->limit - e->ptr) >= bytes);
8153 e->ptr += bytes;
8156 /* Call when all of the bytes for a handler have been written. Flushes the
8157 * bytes if possible and necessary, returning false if this failed. */
8160 /* We aren't inside a delimited region. Flush our accumulated bytes to
8172 /* Writes the given bytes to the buffer, handling reserve/advance. */
8276 uint8_t bytes;
8286 tag->bytes = upb_vencode64((n << 3) | wt, tag->tag);
8293 return encode_bytes(e, tag->tag, tag->bytes);
9458 "Base64 input for bytes field not a multiple of 4: %s",
9484 "Non-base64 characters in bytes field: %s",
9491 /* Last group contains only two input bytes, one output byte. */
9507 /* Last group contains only three input bytes, two output bytes. */
9802 char utf8[3]; /* support \u0000 -- \uFFFF -- need only three bytes. */
12541 * can simply pass the bytes through. */
12840 /* This has to Base64 encode the bytes, because JSON has no "bytes" type. */
12855 size_t bytes;
12864 bytes = to - data;
12865 putstring(p, data, bytes);
12898 bytes = to - data;
12899 putstring(p, data, bytes);