Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-06-06 15:01:25 +0300
committerJacques Lucke <jacques@blender.org>2022-06-06 15:01:25 +0300
commita094cdacf89a18e6fdb167ef8abdc4a79b905fa6 (patch)
treec0ae318c5b3d8c1555b0c09ad74145c79c5db550 /source/blender/blenlib/BLI_virtual_array.hh
parent7eb2018a0bc898537d223306a215ff0edbe371b6 (diff)
BLI: fix memory error when moving VArray_Span
The issue was that the new span still referenced data that was potentially stored in the old VArray_Span.
Diffstat (limited to 'source/blender/blenlib/BLI_virtual_array.hh')
-rw-r--r--source/blender/blenlib/BLI_virtual_array.hh24
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_virtual_array.hh b/source/blender/blenlib/BLI_virtual_array.hh
index 0705d423f01..8f228ea188e 100644
--- a/source/blender/blenlib/BLI_virtual_array.hh
+++ b/source/blender/blenlib/BLI_virtual_array.hh
@@ -1153,6 +1153,30 @@ template<typename T> class VArray_Span final : public Span<T> {
this->data_ = owned_data_.data();
}
}
+
+ VArray_Span(VArray_Span &&other)
+ : varray_(std::move(other.varray_)), owned_data_(std::move(other.owned_data_))
+ {
+ this->size_ = varray_.size();
+ if (varray_.is_span()) {
+ this->data_ = varray_.get_internal_span().data();
+ }
+ else {
+ this->data_ = owned_data_.data();
+ }
+ other.data_ = nullptr;
+ other.size_ = 0;
+ }
+
+ VArray_Span &operator=(VArray_Span &&other)
+ {
+ if (this == &other) {
+ return *this;
+ }
+ std::destroy_at(this);
+ new (this) VArray_Span(std::move(other));
+ return *this;
+ }
};
/**