Skip to content

Commit

Permalink
Merge pull request #261 from toxa81/develop
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
toxa81 authored Sep 17, 2018
2 parents 383c8dd + 2799076 commit 97b3f35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
18 changes: 11 additions & 7 deletions src/SDDK/memory_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ class memory_pool
size_t max_allocated_{0};

template <memory_t mem_type>
void remove_block(std::list<memory_block_descriptor>::iterator& it__)
std::list<memory_block_descriptor>::iterator remove_block(std::list<memory_block_descriptor>::iterator it__)
{
(*it__->used_count_)--;
size_allocated_ -= it__->size_;
if (it__->buf_.use_count() > 1) {
/* this is not the last sub-block: just remove it */
memory_blocks_[mem_type].erase(it__);
return memory_blocks_[mem_type].erase(it__);
} else {
/* this is the last sub-block in the series */
it__->used_ = false;
Expand Down Expand Up @@ -92,6 +92,8 @@ class memory_pool
/* if next block is not used and its memory is not shared with other blocks */
merge_blocks(it1);
}
it__++;
return it__;
}
}

Expand Down Expand Up @@ -172,14 +174,16 @@ class memory_pool
/* iterate over memory blocks */
auto it = mem_type_entry->second.begin();
while (it != mem_type_entry->second.end()) {
auto it1 = it++;
if (it1->used_) {
remove_block<mem_type>(it1);
}
it = remove_block<mem_type>(it);
}
it = mem_type_entry->second.begin();
if (mem_type_entry->second.size() != 1 || it->used_ || (it->size_ != it->buf_->size())) {
TERMINATE("error in memory_pool::reset()");
std::stringstream s;
s << "error in memory_pool::reset()\n"
<< " list size : " << mem_type_entry->second.size() << " (expecting 1)\n"
<< " used : " << it->used_ << " (expecting false)\n"
<< " buffer size : " << it->size_ << " " << it->buf_->size() << " (expecting equal)";
TERMINATE(s);
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/spline.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@ class Spline: public Radial_grid<U>
{
int j = this->index_of(x);
if (j == -1) {
TERMINATE("point not found");
std::stringstream s;
s << "spline::at_point() index of point is not found\n"
<< " x : " << x << "\n"
<< " first point : " << this->first() << "\n"
<< " last point : " << this->last();
TERMINATE(s);
}
U dx = x - (*this)[j];
return (*this)(j, dx);
Expand Down

0 comments on commit 97b3f35

Please sign in to comment.