From cad1db07d55c17833e4b308a9c303b369217f125 Mon Sep 17 00:00:00 2001 From: gfgtdf Date: Sat, 21 Jun 2014 03:31:20 +0200 Subject: [PATCH] replace a warning with an assert. 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. --- src/unit.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/unit.cpp b/src/unit.cpp index 0d9ff9cf5d04..06ea00fe6056 100644 --- a/src/unit.cpp +++ b/src/unit.cpp @@ -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; }