Lines Matching defs:size

215         /// That means we can check the size just once, then just read directly from the buffer
429 /// Reads a fixed size of bytes from the input.
434 public static byte[] ReadRawBytes(ref ReadOnlySpan<byte> buffer, ref ParserInternalState state, int size)
436 if (size < 0)
441 if (size <= state.bufferSize - state.bufferPos)
444 byte[] bytes = new byte[size];
445 buffer.Slice(state.bufferPos, size).CopyTo(bytes);
446 state.bufferPos += size;
450 return ReadRawBytesSlow(ref buffer, ref state, size);
453 private static byte[] ReadRawBytesSlow(ref ReadOnlySpan<byte> buffer, ref ParserInternalState state, int size)
455 ValidateCurrentLimit(ref buffer, ref state, size);
457 if ((!state.segmentedBufferHelper.TotalLength.HasValue && size < buffer.Length) ||
458 IsDataAvailableInSource(ref state, size))
463 byte[] bytes = new byte[size];
464 ReadRawBytesIntoSpan(ref buffer, ref state, size, bytes);
469 // The size is very large. For security reasons, we can't allocate the
470 // entire byte array yet. The size comes directly from the input, so a
471 // maliciously-crafted message could provide a bogus very large size in
475 // problems. Meanwhile, we limit the allowed size of a message elsewhere.
486 int sizeLeft = size - pos;
500 byte[] bytes = new byte[size];
514 /// Reads and discards <paramref name="size"/> bytes.
518 public static void SkipRawBytes(ref ReadOnlySpan<byte> buffer, ref ParserInternalState state, int size)
520 if (size < 0)
525 ValidateCurrentLimit(ref buffer, ref state, size);
527 if (size <= state.bufferSize - state.bufferPos)
530 state.bufferPos += size;
543 while (size - pos > state.bufferSize)
550 state.bufferPos = size - pos;
670 /// Validates that the specified size doesn't exceed the current limit. If it does then remaining bytes
673 private static void ValidateCurrentLimit(ref ReadOnlySpan<byte> buffer, ref ParserInternalState state, int size)
675 if (state.totalBytesRetired + state.bufferPos + size > state.currentLimit)
765 /// Checks whether there is known data available of the specified size remaining to parse.
769 public static bool IsDataAvailable(ref ParserInternalState state, int size)
772 if (size <= state.bufferSize - state.bufferPos)
777 return IsDataAvailableInSource(ref state, size);
781 /// Checks whether there is known data available of the specified size remaining to parse
786 private static bool IsDataAvailableInSource(ref ParserInternalState state, int size)
790 return size <= state.segmentedBufferHelper.TotalLength - state.totalBytesRetired - state.bufferPos;