pw_multibuf: Restructure ChunkIterable MultiBuf is a byte-oriented view of a list of chunks, and this change structures MultiBuf accordingly. This replaces the ChunkIterable class with a private MultiBufChunks base class that provides the Chunk-oriented view for MultiBuf. Restructuring this way fixes an issue where MultiBuf data can be modified from a const reference. MultiBuf originally returned a const ChunkIterable, but since return values are copied, this becomes a non-const ChunkIterable, giving mutable access to the multibuf. const MultiBuf& const_mb = mb; auto chunk_iterable = cmb.Chunks(); // chunk_iterable is non-const iterable.front()[0] = std::byte(); // uh oh, chunk data is mutable! Change-Id: I9819eb23c9cdf745691ba15b20648b824620cf68 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/230892 Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com> Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com> Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com> Reviewed-by: Taylor Cramer <cramertj@google.com>
Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.
For more information please see our website: https://pigweed.dev/.