diff options
author | Jacques Lucke <jacques@blender.org> | 2022-09-10 13:59:51 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-09-10 13:59:51 +0300 |
commit | aa7669939390cd1c72e5a25f9b16e935e0263f2a (patch) | |
tree | bb770c549a4ffd344918a37c9b92ce213a5f1b13 /source/blender/blenlib | |
parent | d64acada22e2bbdd3aa6057acdc83ae56f7da926 (diff) |
progress
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_chunk_list.hh | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/source/blender/blenlib/BLI_chunk_list.hh b/source/blender/blenlib/BLI_chunk_list.hh index 321bb4c7d0a..7d4f216d007 100644 --- a/source/blender/blenlib/BLI_chunk_list.hh +++ b/source/blender/blenlib/BLI_chunk_list.hh @@ -224,7 +224,13 @@ class ChunkList { { this->ensure_space_for_one(); BLI_assert(active_end_ < active_capacity_end_); - new (active_end_) T(std::forward<Args>(args)...); + try { + new (active_end_) T(std::forward<Args>(args)...); + } + catch (...) { + this->move_end_back_to_prev_element(); + throw; + } active_end_++; } @@ -261,15 +267,20 @@ class ChunkList { T value = std::move(*(active_end_ - 1)); active_end_--; std::destroy_at(active_end_); + this->move_end_back_to_prev_element(); + return value; + } + void move_end_back_to_prev_element() + { if (active_end_ > active_begin_) { - return value; + return; } if (alloc_info_ == nullptr) { - return value; + return; } if (alloc_info_->active_chunk == 0) { - return value; + return; } RawChunk &old_chunk = alloc_info_->raw_chunks[alloc_info_->active_chunk]; old_chunk.end_if_inactive = active_end_; @@ -286,7 +297,6 @@ class ChunkList { active_begin_ = new_chunk.begin; active_end_ = new_chunk.end_if_inactive; active_capacity_end_ = new_chunk.capacity_end; - return value; } class Iterator { |