bool unit_map::self_check() const { bool found_the_end(false), good(true); t_ilist::const_iterator lit(ilist_.begin()); for(; lit != ilist_.end(); ++lit){ if(lit == the_end_){ found_the_end = true; continue; } if(lit->ref_count < 0){ good=false; ERR_NG << "unit_map list element ref_count <0 is " << lit->ref_count<<"\n"; } if(lit->unit != NULL){ lit->unit->id(); //crash if bad pointer } else { if(lit->ref_count <= 0){ good=false; ERR_NG << "unit_map list element ref_count <=0 is " << lit->ref_count<<", when unit deleted.\n"; } if(lit->deleted_uid <= 0 ){ good=false; ERR_NG << "unit_map list element deleted_uid <=0 is " << lit->deleted_uid<<"\n"; } } } if(!found_the_end){ good=false; ERR_NG << "unit_map list the_end_ is missing. " <<"\n";} t_umap::const_iterator uit(umap_.begin()); for(; uit != umap_.end(); ++uit){ if(uit->first <= 0){ good=false; ERR_NG << "unit_map umap uid <=0 is " << uit->first <<"\n"; } if(uit->second == the_end_ ){ good=false; ERR_NG << "unit_map umap element == the_end_ "<<"\n"; } if(uit->second->unit == NULL && uit->second->ref_count == 0 ){ good=false; ERR_NG << "unit_map umap unit==NULL when refcount == 0 uid="<<uit->second->deleted_uid<<"\n"; } if(uit->second->unit && uit->second->unit->underlying_id() != uit->first){ good=false; ERR_NG << "unit_map umap uid("<<uit->first<<") != underlying_id()["<< uit->second->unit->underlying_id()<< "]\n"; } } t_lmap::const_iterator locit(lmap_.begin()); for(; locit != lmap_.end(); ++locit){ if(locit->second == the_end_ ){ good=false; ERR_NG << "unit_map lmap element == the_end_ "<<"\n"; } if(locit->first != locit->second->unit->get_location()){ good=false; ERR_NG << "unit_map lmap location != unit->get_location() " <<"\n"; } } //assert(good); return good; }
bool unit_map::self_check() const { #ifdef DEBUG_UNIT_MAP bool good(true); umap::const_iterator uit(umap_.begin()); for(; uit != umap_.end(); ++uit) { if(uit->second.ref_count < 0) { good = false; ERR_NG << "unit_map pod ref_count <0 is " << uit->second.ref_count << std::endl; } if(uit->second.unit) { uit->second.unit->id(); // crash if bad pointer } if(uit->first <= 0) { good = false; ERR_NG << "unit_map umap uid <=0 is " << uit->first << std::endl; } if(!uit->second.unit && uit->second.ref_count == 0) { good = false; ERR_NG << "unit_map umap unit==nullptr when refcount == 0" << std::endl; } if(uit->second.unit && uit->second.unit->underlying_id() != uit->first) { good = false; ERR_NG << "unit_map umap uid(" << uit->first << ") != underlying_id()[" << uit->second.unit->underlying_id() << "]" << std::endl; } } lmap::const_iterator locit(lmap_.begin()); for(; locit != lmap_.end(); ++locit) { if(locit->second == umap_.end()) { good = false; ERR_NG << "unit_map lmap element == umap_.end() " << std::endl; } if(locit->first != locit->second->second.unit->get_location()) { good = false; ERR_NG << "unit_map lmap location != unit->get_location() " << std::endl; } } // assert(good); return good; #else return true; #endif }