static void UnregisterBlock(MEMINFO *block) { if (!MonitoringEnabled) return; EnterCriticalSection(&CS); if (block->prev) block->prev->next = block->next; if (block->next) block->next->prev = block->prev; if(block == LastMemBlock) LastMemBlock = LastMemBlock->prev; CheckChain(); updateCallCount(block->AllocationType, false); --AllocatedMemoryBlocks; AllocatedMemorySize-=block->Size; LeaveCriticalSection(&CS); if (!AllocatedMemoryBlocks) DeleteCriticalSection(&CS); }
Path::Path(const Coordinates& sp_coords, const Field* new_pfield): clr(new_pfield->GetColor(sp_coords)), field(new_pfield), path_created(false), enemy_point_inside(false), sp(sp_coords) { Path::SearchResult sr = field->SearchNearby(sp); if(sr.amount >= 2){ Dots to_skip; //container to store dots that we must skip //clearing all the containers tr.clear(); path.clear(); to_skip.clear(); //appending start point as a root Path::Iter root = tr.insert(tr.begin(), sp); //assigning first points for(int i = 0; i <= sr.amount; i++){ Build(sr.find_coords[i], root, to_skip, sp); to_skip.clear(); } //here we'll get the path //vector of all availiable iterators from //root to any copy of start point in tree std::vector<Path::Iter> iters; Path::Iter it = root; it++; //finding all the copies of the first point in the tree while(it!=tr.end()){ if(*it == sp) iters.push_back(it); it++; } //if any copy found... if(!iters.empty()){ //we add parent of current point to path, then we make this parent to be current point for(size_t i = 0; i < iters.size(); i++){ Path::Iter cur = iters[i]; while(cur != root){ path.push_back(*cur); cur = tr.parent(cur); } path.push_back(sp); } //if any copy was found then it will be at least one path. That means that path is created path_created = true; CheckChain(); //check chain to have enemy dot inside } //clearing containers tr.clear(); to_skip.clear(); } }
static void RegisterBlock(MEMINFO *block) { if (!MonitoringEnabled) return; if (!AllocatedMemoryBlocks) InitializeCriticalSection(&CS); EnterCriticalSection(&CS); block->prev = LastMemBlock; block->next = nullptr; LastMemBlock->next = block; LastMemBlock = block; CheckChain(); updateCallCount(block->AllocationType, true); ++AllocatedMemoryBlocks; ++TotalAllocationCalls; AllocatedMemorySize+=block->Size; LeaveCriticalSection(&CS); }
int main(int argc, char **argv) { CHAIN **Chain; HBOND **HBond; COMMAND *Cmd; int Cn, NChain=0, NHBond=0, ValidChain=0; float **PhiPsiMapHelix, **PhiPsiMapSheet; register int i; /* argc = ccommand(&argv); */ /* For Macintosh only, see readme.mac */ Chain = (CHAIN **)ckalloc(MAX_CHAIN*sizeof(CHAIN *)); HBond = (HBOND **)ckalloc(MAXHYDRBOND*sizeof(HBOND *)); Cmd = (COMMAND *)ckalloc(sizeof(COMMAND)); ProcessStrideOptions(argv,argc,Cmd); if( !ReadPDBFile(Chain,&NChain,Cmd) || !NChain ) die("Error reading PDB file %s\n",Cmd->InputFile); for( Cn=0; Cn<NChain; Cn++ ) ValidChain += CheckChain(Chain[Cn],Cmd); /* if( Cmd->Stringent ) * exit(0); */ if( !ValidChain ) die("No valid chain in %s\n",Chain[0]->File); if( Cmd->BrookhavenAsn ) GetPdbAsn(Chain,NChain); if( Cmd->DsspAsn ) GetDsspAsn(Chain,NChain,Cmd); BackboneAngles(Chain,NChain); if( Cmd->OutSeq ) OutSeq(Chain,NChain,Cmd); if( Cmd->ContactOrder ) ContactOrder(Chain,NChain,Cmd); if( Cmd->ContactMap ) ContactMap(Chain,NChain,Cmd); if( !strlen(Cmd->MapFileHelix) ) PhiPsiMapHelix = DefaultHelixMap(Cmd); else ReadPhiPsiMap(Cmd->MapFileHelix,&PhiPsiMapHelix,Cmd); if( !strlen(Cmd->MapFileSheet) ) PhiPsiMapSheet = DefaultSheetMap(Cmd); else ReadPhiPsiMap(Cmd->MapFileSheet,&PhiPsiMapSheet,Cmd); for( Cn=0; Cn<NChain; Cn++ ) PlaceHydrogens(Chain[Cn]); if( (NHBond = FindHydrogenBonds(Chain,Cn,HBond,Cmd)) == 0 ) die("No hydrogen bonds found in %s\n",Cmd->InputFile); NoDoubleHBond(HBond,NHBond); DiscrPhiPsi(Chain,NChain,Cmd); if(Cmd->ExposedArea) Area(Chain,NChain,Cmd); for( Cn=0; Cn<NChain; Cn++ ) { if( Chain[Cn]->Valid ) { Helix(Chain,Cn,HBond,Cmd,PhiPsiMapHelix); for( i=0; i<NChain; i++ ) if( Chain[i]->Valid ) Sheet(Chain,Cn,i,HBond,Cmd,PhiPsiMapSheet); BetaTurn(Chain,Cn); GammaTurn(Chain,Cn,HBond); } } Report(Chain,NChain,HBond,Cmd); if( Cmd->MolScript ) MolScript(Chain,NChain,Cmd); for( i=0; i<Cn; i++ ) free(Chain[i]); for( i=0; i<NHBond; i++ ) free(HBond[i]); free(Cmd); return(0); }