Skip to content

Commit

Permalink
replace a warning with an assert.
Browse files Browse the repository at this point in the history
the warning was a temporary because there was a bug in the code that would have caused this assertion to fail. Since that bugs was fixed, i replaced it with an assert.
  • Loading branch information
gfgtdf committed Jun 21, 2014
1 parent 9de5d02 commit cad1db0
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/unit.cpp
Expand Up @@ -79,19 +79,20 @@ namespace {

void intrusive_ptr_add_ref(const unit * u)
{
if(u->ref_count_ > 1000 || u->ref_count_ < 0)
{
WRN_UT << "found very much references: " << u->ref_count_ << " of them " << std::endl;
}
assert(u->ref_count_ >= 0);
// the next code line is to notice possible wrongly intilized units.
// The 100000 is picked rather randomly. If you are in the situation
// that you can actualy have more then 100000 intrusive_ptr to one unit
// or if you are sure that the refcounting system works
// then feel free to remove the next line
assert(u->ref_count_ < 100000);
++(u->ref_count_);
}

void intrusive_ptr_release(const unit * u)
{
if(u->ref_count_ > 1000 || u->ref_count_ < 0)
{
WRN_UT << "found very much references: " << u->ref_count_ << " of them " << std::endl;
}
assert(u->ref_count_ >= 1);
assert(u->ref_count_ < 100000); //See comment in intrusive_ptr_add_ref
if (--(u->ref_count_) == 0)
delete u;
}
Expand Down

0 comments on commit cad1db0

Please sign in to comment.