Commit aee861c0 authored by Max Kellermann's avatar Max Kellermann Committed by Max Kellermann

util/AllocatedArray: copy constructor copies "nulled" state

parent 2cc1dd28
......@@ -62,11 +62,13 @@ public:
assert(size() == 0 || buffer.data != nullptr);
}
explicit AllocatedArray(const AllocatedArray &other) noexcept
:buffer{new T[other.buffer.size], other.buffer.size} {
assert(size() == 0 || buffer.data != nullptr);
explicit AllocatedArray(const AllocatedArray &other) noexcept {
assert(other.size() == 0 || other.buffer.data != nullptr);
if (other == nullptr)
return;
buffer = {new T[other.buffer.size], other.buffer.size};
std::copy_n(other.buffer.data, buffer.size, buffer.data);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment