[sm_recursive] Fix bug that allowed the same block to be allocated twice.

See issue 70.  Soln from mingnus.
This commit is contained in:
Joe Thornber 2017-03-29 14:58:12 +01:00 committed by Ming-Hung Tsai
parent 0f2918e989
commit 4cdffafe88

View File

@ -97,6 +97,12 @@ namespace {
add_op(b, block_op(SET, c));
else {
recursing_lock lock(*this);
// the inner set_count may trigger a find_free,
// so it's important we update the allocated
// blocks list before calling.
allocated_blocks_.add(b, b + 1);
return sm_->set_count(b, c);
}
}
@ -111,6 +117,12 @@ namespace {
add_op(b, block_op(INC, count));
else {
recursing_lock lock(*this);
// the inner inc() may trigger a find_free,
// so it's important we update the allocated
// blocks list before calling.
allocated_blocks_.add(b, b + 1);
return sm_->inc(b, count);
}
}