Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ChunkContainer.hpp #152

Merged
merged 8 commits into from
Nov 30, 2024
23 changes: 14 additions & 9 deletions src/XAD/ChunkContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,20 @@ class ChunkContainer
}

ChunkContainer(ChunkContainer&& o) noexcept
: chunkList_(std::move(o.chunkList_)), chunk_(o.chunk_), idx_(o.idx_)
{
: chunkList_(std::move(o.chunkList_)), chunk_(o.chunk_), idx_(o.idx_) {
o.chunk_ = 0;
o.idx_ = 0;
}

ChunkContainer& operator=(ChunkContainer&& o)
{
_free_memory();
chunkList_ = std::move(o.chunkList_);
chunk_ = o.chunk_;
idx_ = o.idx_;
ChunkContainer& operator=(ChunkContainer&& o) noexcept {
if (this != &o) {
_free_memory();
chunkList_ = std::move(o.chunkList_);
chunk_ = o.chunk_;
idx_ = o.idx_;
o.chunk_ = 0;
o.idx_ = 0;
}
return *this;
}

Expand Down Expand Up @@ -445,8 +449,9 @@ class ChunkContainer
{
char* chunk = reinterpret_cast<char*>(
detail::aligned_alloc(ALIGNMENT, sizeof(value_type) * chunk_size));
if (chunk == NULL)
if (chunk == nullptr) {
throw std::bad_alloc();
}
chunkList_.push_back(chunk);
}
++chunk_;
Expand Down
Loading