commit | 5733a0e4d599dbc700692d1b04be3bb09030b6a2 | [log] [tgz] |
---|---|---|
author | Erik Gilling <konkers@google.com> | Mon Jan 24 21:59:49 2022 +0000 |
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | Wed Jan 26 23:55:44 2022 +0000 |
tree | f8daf728b53d4ea5d6c809886d0d8bae311ec239 | |
parent | 2ebc8cb4594e22f9fb0a758e8276e0e02fe7eb67 [diff] |
pw_containers: Make list iterators safe against deletion Before this change, if an element is deleted while iterating over the list, the iteration would never terminate because the current item's next pointer now points to itself. This patch adds a shadow copy of the current item's next pointer to the iterator and uses that when incrementing instead of the current item's next pointer. After this change, the following code safe: for (auto &item : list) { list.remote(item); } Change-Id: I1cd7c051df56e3a8e19a86533c24b1e9f9531c61 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/81447 Reviewed-by: Keir Mierle <keir@google.com> Commit-Queue: Erik Gilling <konkers@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/