// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifdef UNSAFE_BUFFERS_BUILD // TODO(crbug.com/40285824): Remove this and convert code to safer constructs. #pragma allow_unsafe_buffers #endif #include "components/zucchini/buffer_source.h" #include "base/ranges/algorithm.h" #include "components/zucchini/algorithm.h" namespace zucchini { BufferSource::BufferSource(const ConstBufferView& buffer) : … { … } BufferSource::BufferSource(const ConstBufferView& buffer, size_type offset) : … { … } bool BufferSource::Skip(size_type n) { … } bool BufferSource::CheckNextBytes(std::initializer_list<uint8_t> bytes) const { … } bool BufferSource::ConsumeBytes(std::initializer_list<uint8_t> bytes) { … } bool BufferSource::GetRegion(size_type count, ConstBufferView* buffer) { … } // [0aaaaaaa] => 00000000'00000000'00000000'0aaaaaaa // [1aaaaaaa 0bbbbbbb] => 00000000'00000000'00bbbbbb'baaaaaaa // [1aaaaaaa 1bbbbbbb 0ccccccc] => 00000000'000ccccc'ccbbbbbb'baaaaaaa // [1aaaaaaa 1bbbbbbb 1ccccccc 0ddddddd] => 0000dddd'dddccccc'ccbbbbbb'baaaaaaa // [1aaaaaaa 1bbbbbbb 1ccccccc 1ddddddd 0???eeee] // => eeeedddd'dddccccc'ccbbbbbb'baaaaaaa // Note that "???" is discarded. Meanwhile, 1???eeee is invalid. bool BufferSource::GetUleb128(uint32_t* ret) { … } // [0Saaaaaa] => SSSSSSSS'SSSSSSSS'SSSSSSSS'SSaaaaaa // [1aaaaaaa 0Sbbbbbb] => SSSSSSSS'SSSSSSSS'SSSbbbbb'baaaaaaa // [1aaaaaaa 1bbbbbbb 0Scccccc] => SSSSSSSS'SSSScccc'ccbbbbbb'baaaaaaa // [1aaaaaaa 1bbbbbbb 1ccccccc 0Sdddddd] => SSSSSddd'dddccccc'ccbbbbbb'baaaaaaa // [1aaaaaaa 1bbbbbbb 1ccccccc 1ddddddd 0???Seee] // => Seeedddd'dddccccc'ccbbbbbb'baaaaaaa // Note that "???" is discarded. Meanwhile, 1???eeee is invalid. bool BufferSource::GetSleb128(int32_t* ret) { … } bool BufferSource::SkipLeb128() { … } } // namespace zucchini