bool find_sql_updates() { printf("+ finding new sql updates on HEAD\n"); // add all updates from HEAD snprintf(cmd, MAX_CMD, "git show HEAD:%s", sql_update_dir); if( (cmd_pipe = popen( cmd, "r" )) == NULL ) return false; // skip first two lines if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } sql_update_info info; while(fgets(buffer, MAX_BUF, cmd_pipe)) { buffer[strlen(buffer) - 1] = '\0'; if(!get_sql_update_info(buffer, info)) continue; if(info.db_idx == NUM_DATABASES) { if(info.rev > 0) printf("WARNING: incorrect database name for sql update %s\n", buffer); continue; } new_sql_updates.insert(buffer); } pclose(cmd_pipe); // remove updates from the last commit also found on origin snprintf(cmd, MAX_CMD, "git show %s:%s", origin_hash, sql_update_dir); if( (cmd_pipe = popen( cmd, "r" )) == NULL ) return false; // skip first two lines if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } while(fgets(buffer, MAX_BUF, cmd_pipe)) { buffer[strlen(buffer) - 1] = '\0'; if(!get_sql_update_info(buffer, info)) continue; // find the old update with the highest rev for each database // (will be the required version for the new update) std::set<std::string>::iterator itr = new_sql_updates.find(buffer); if(itr != new_sql_updates.end() ) { if(info.rev > 0 && (info.rev > last_sql_rev[info.db_idx] || (info.rev == last_sql_rev[info.db_idx] && info.nr > last_sql_nr[info.db_idx]))) { last_sql_rev[info.db_idx] = info.rev; last_sql_nr[info.db_idx] = info.nr; if(db_sql_rev_parent[info.db_idx]) snprintf(last_sql_update[info.db_idx], MAX_PATH, "%s_%0*d_%s%s%s", info.parentRev, 2, info.nr, info.db, info.has_table ? "_" : "", info.table); else sscanf(buffer, "%[^.]", last_sql_update[info.db_idx]); } new_sql_updates.erase(itr); } } pclose(cmd_pipe); if(!new_sql_updates.empty()) { for(std::set<std::string>::iterator itr = new_sql_updates.begin(); itr != new_sql_updates.end(); ++itr) printf("%s\n", itr->c_str()); } else printf("WARNING: no new sql updates found.\n"); return true; }
void consume( action a ) { actions.erase( a ); }
void halo_impl::unrender(std::set<map_location> invalidated_locations) { if(preferences::show_haloes() == false || haloes.empty()) { return; } //assert(invalidated_haloes.empty()); // Remove expired haloes std::map<int, effect>::iterator itor = haloes.begin(); for(; itor != haloes.end(); ++itor ) { if(itor->second.expired()) { deleted_haloes.insert(itor->first); } } // Add the haloes marked for deletion to the invalidation set std::set<int>::const_iterator set_itor = deleted_haloes.begin(); for(;set_itor != deleted_haloes.end(); ++set_itor) { invalidated_haloes.insert(*set_itor); haloes.find(*set_itor)->second.add_overlay_location(invalidated_locations); } // Test the multi-frame haloes whether they need an update for(set_itor = changing_haloes.begin(); set_itor != changing_haloes.end(); ++set_itor) { if(haloes.find(*set_itor)->second.need_update()) { invalidated_haloes.insert(*set_itor); haloes.find(*set_itor)->second.add_overlay_location(invalidated_locations); } } // Find all halo's in a the invalidated area size_t halo_count; // Repeat until set of haloes in the invalidated area didn't change // (including none found) or all existing haloes are found. do { halo_count = invalidated_haloes.size(); for(itor = haloes.begin(); itor != haloes.end(); ++itor) { // Test all haloes not yet in the set // which match one of the locations if(invalidated_haloes.find(itor->first) == invalidated_haloes.end() && (itor->second.location_not_known() || itor->second.on_location(invalidated_locations))) { // If found, add all locations which the halo invalidates, // and add it to the set itor->second.add_overlay_location(invalidated_locations); invalidated_haloes.insert(itor->first); } } } while (halo_count != invalidated_haloes.size() && halo_count != haloes.size()); if(halo_count == 0) { return; } // Render the haloes: // iterate through all the haloes and invalidate if in set for(std::map<int, effect>::reverse_iterator ritor = haloes.rbegin(); ritor != haloes.rend(); ++ritor) { if(invalidated_haloes.find(ritor->first) != invalidated_haloes.end()) { ritor->second.unrender(); } } // Really delete the haloes marked for deletion for(set_itor = deleted_haloes.begin(); set_itor != deleted_haloes.end(); ++set_itor) { // It can happen a deleted halo hasn't been rendered yet, invalidate them as well new_haloes.erase(*set_itor); changing_haloes.erase(*set_itor); invalidated_haloes.erase(*set_itor); haloes.erase(*set_itor); } deleted_haloes.clear(); }
IGL_INLINE bool igl::collapse_edge( const std::function<void( const int, const Eigen::MatrixXd &, const Eigen::MatrixXi &, const Eigen::MatrixXi &, const Eigen::VectorXi &, const Eigen::MatrixXi &, const Eigen::MatrixXi &, double &, Eigen::RowVectorXd &)> & cost_and_placement, Eigen::MatrixXd & V, Eigen::MatrixXi & F, Eigen::MatrixXi & E, Eigen::VectorXi & EMAP, Eigen::MatrixXi & EF, Eigen::MatrixXi & EI, std::set<std::pair<double,int> > & Q, std::vector<std::set<std::pair<double,int> >::iterator > & Qit, Eigen::MatrixXd & C, int & e, int & e1, int & e2, int & f1, int & f2) { using namespace Eigen; if(Q.empty()) { // no edges to collapse return false; } std::pair<double,int> p = *(Q.begin()); if(p.first == std::numeric_limits<double>::infinity()) { // min cost edge is infinite cost return false; } Q.erase(Q.begin()); e = p.second; Qit[e] = Q.end(); std::vector<int> N = circulation(e, true,F,E,EMAP,EF,EI); std::vector<int> Nd = circulation(e,false,F,E,EMAP,EF,EI); N.insert(N.begin(),Nd.begin(),Nd.end()); const bool collapsed = collapse_edge(e,C.row(e),V,F,E,EMAP,EF,EI,e1,e2,f1,f2); if(collapsed) { // Erase the two, other collapsed edges Q.erase(Qit[e1]); Qit[e1] = Q.end(); Q.erase(Qit[e2]); Qit[e2] = Q.end(); // update local neighbors // loop over original face neighbors for(auto n : N) { if(F(n,0) != IGL_COLLAPSE_EDGE_NULL || F(n,1) != IGL_COLLAPSE_EDGE_NULL || F(n,2) != IGL_COLLAPSE_EDGE_NULL) { for(int v = 0;v<3;v++) { // get edge id const int ei = EMAP(v*F.rows()+n); // erase old entry Q.erase(Qit[ei]); // compute cost and potential placement double cost; RowVectorXd place; cost_and_placement(ei,V,F,E,EMAP,EF,EI,cost,place); // Replace in queue Qit[ei] = Q.insert(std::pair<double,int>(cost,ei)).first; C.row(ei) = place; } } } }else { // reinsert with infinite weight (the provided cost function must **not** // have given this un-collapsable edge inf cost already) p.first = std::numeric_limits<double>::infinity(); Qit[e] = Q.insert(p).first; } return collapsed; }
SceneNode::~SceneNode() { scene_.erase(scene_.find(this)); }
void leave(player::pointer player) { players_.erase(player); }
void Unregister() { ShouldBe(); ActiveObjects.erase(this); }
void ECB::removeDate(const Date& d) { knownDates(); // just to ensure inizialization knownDateSet.erase(d); }
unsigned int InternalGraph::selectVertex(AntPath* pt, unsigned int cur, std::set<unsigned int> & available, bool& s, std::map<Element *, std::set<Link *> >& chan) { // choose request unsigned int vertex = 0; unsigned int size = available.size(); std::vector<double> roulette(size); std::vector<unsigned int> rouletteIndex(size); double value = 0, sum = 0; unsigned int index = 0; std::set<unsigned int>::iterator itEnd = available.end(); for (std::set<unsigned int>::iterator i = available.begin(); i != itEnd; i ++, index ++) { value = pow(arcs[cur][*i]->pher, pherDeg)*pow(arcs[cur][*i]->heur, heurDeg); sum += value; roulette[index] = sum; rouletteIndex[index] = *i; } double choose = rand()/(double)RAND_MAX * sum; if (ZERO(sum)) { std::set<unsigned int>::iterator sel = available.begin(); vertex = *sel; available.erase(sel); } else { for (unsigned int i = 0; i < size; ++ i) { if (choose < roulette[i]) { vertex = rouletteIndex[i]; unsigned int res = available.erase(rouletteIndex[i]); assert(res == 1); break; } } } // choose resource GraphComponent * gc = vertices[vertex-1]; unsigned int res = gc->chooseResource(curNodesRam, pherDeg, heurDeg); if (res >= gc->getResNum()) { // failed to choose a resource s = false; return vertex; } if (gc->getType() == GraphComponent::VMACHINE) { curNodesRes[res] -= gc->getRequired(); curNodesRam[res] -= gc->getRequiredRam(); updateInternalHeuristic(res, GraphComponent::VMACHINE); std::map<Element *, std::set<Link *> >::iterator iter = chan.find(gc->getPointer()); std::set<Link *> * chanPtr = (iter != chan.end()) ? &(iter->second) : NULL; pt->addElement(new PathElement(vertex, gc->getPointer(), res, physNodes[res], chanPtr)); } else if (gc->getType() == GraphComponent::STORAGE) { curStoresRes[res] -= gc->getRequired(); updateInternalHeuristic(res, GraphComponent::STORAGE); std::map<Element *, std::set<Link *> >::iterator iter = chan.find(gc->getPointer()); std::set<Link *> * chanPtr = (iter != chan.end()) ? &(iter->second) : NULL; pt->addElement(new PathElement(vertex, gc->getPointer(), res, physStores[res], chanPtr)); } s = true; return vertex; }
void OGRDataSourceWithTransaction::ReleaseResultSet( OGRLayer * poResultsSet ) { if( !m_poBaseDataSource ) return; m_oSetExecuteSQLLayers.erase(poResultsSet); m_poBaseDataSource->ReleaseResultSet(poResultsSet); }
void erase(const FileEntry *Entry) { UniqueFiles.erase(*Entry); }
virtual void destroyed(LinuxDynamicLibModel<Base>* model) { _models.erase(model); }
//***************************************************************************** // void MASTERSERVER_ParseCommands( BYTESTREAM_s *pByteStream ) { long lCommand; NETADDRESS_s AddressFrom; AddressFrom = NETWORK_GetFromAddress( ); // [RC] If this IP is in our flood queue, ignore it completely. if ( g_floodProtectionIPQueue.addressInQueue( AddressFrom ) || g_ShortFloodQueue.addressInQueue( AddressFrom )) { while ( NETWORK_ReadByte( pByteStream ) != -1 ) // [RC] Is this really necessary? ; return; } // Is this IP banned? Send the user an explanation, and ignore the IP for 30 seconds. if ( !g_BannedIPExemptions.isIPInList( AddressFrom ) && g_BannedIPs.isIPInList( AddressFrom )) { NETWORK_ClearBuffer( &g_MessageBuffer ); NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_IPISBANNED ); NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); printf( "* Received challenge from banned IP (%s). Ignoring for 10 seconds.\n", NETWORK_AddressToString( AddressFrom )); g_queryIPQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr ); return; } lCommand = NETWORK_ReadLong( pByteStream ); switch ( lCommand ) { // Server is telling master server of its existence. case SERVER_MASTER_CHALLENGE: { // Certain IPs can be blocked from just hosting. if ( !g_BannedIPExemptions.isIPInList( AddressFrom ) && g_BlockedIPs.isIPInList( AddressFrom )) { NETWORK_ClearBuffer( &g_MessageBuffer ); NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_IPISBANNED ); NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); printf( "* Received server challenge from blocked IP (%s). Ignoring for 10 seconds.\n", NETWORK_AddressToString( AddressFrom )); g_queryIPQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr ); return; } SERVER_s newServer; newServer.Address = AddressFrom; // [BB] If no verification string was send, NETWORK_ReadString just returns an empty string. // Thus, this is still compatible with older servers that don't send the string. newServer.MasterBanlistVerificationString = NETWORK_ReadString( pByteStream ); // [BB] If no value was send, NETWORK_ReadByte just returns -1. // Thus, this is still compatible with older servers that don't tell us whether they enforce our bans // and gives them the benefit of the doubt, i.e. it assumes that they enforce our bans. const int temp = NETWORK_ReadByte( pByteStream ); newServer.bEnforcesBanList = ( temp != 0 ); newServer.bNewFormatServer = ( temp != -1 ); newServer.iServerRevision = ( ( pByteStream->pbStreamEnd - pByteStream->pbStream ) >= 4 ) ? NETWORK_ReadLong( pByteStream ) : NETWORK_ReadShort( pByteStream ); std::set<SERVER_s, SERVERCompFunc>::iterator currentServer = g_Servers.find ( newServer ); // This is a new server; add it to the list. if ( currentServer == g_Servers.end() ) { unsigned int iNumOtherServers = 0; // First count the number of servers from this IP. for( std::set<SERVER_s, SERVERCompFunc>::const_iterator it = g_Servers.begin(); it != g_Servers.end(); ++it ) { if ( NETWORK_CompareAddress( it->Address, AddressFrom, true )) iNumOtherServers++; } if ( iNumOtherServers >= 10 && !g_MultiServerExceptions.isIPInList( AddressFrom )) printf( "* More than 10 servers received from %s. Ignoring request...\n", NETWORK_AddressToString( AddressFrom )); else { // [BB] 3021 is 98d, don't put those servers on the list. if ( ( newServer.bNewFormatServer ) && ( newServer.iServerRevision != 3021 ) ) { std::set<SERVER_s, SERVERCompFunc>::iterator currentUnverifiedServer = g_UnverifiedServers.find ( newServer ); // [BB] This is a new server, but we still need to verify it. if ( currentUnverifiedServer == g_UnverifiedServers.end() ) { srand ( time(NULL) ); newServer.ServerVerificationInt = rand() + rand() * rand() + rand() * rand() * rand(); // [BB] We don't send the ban list to unverified servers, so just pretent the server already has the list. newServer.bHasLatestBanList = true; MASTERSERVER_RequestServerVerification ( newServer ); MASTERSERVER_AddServer( newServer, g_UnverifiedServers ); } } else { printf( "* Received server challenge from old server (%s). Ignoring IP for 10 seconds.\n", NETWORK_AddressToString( newServer.Address )); g_queryIPQueue.addAddress( newServer.Address, g_lCurrentTime, &std::cerr ); } } } // Command is from a server already on the list. It's just sending us a heartbeat. else { // [BB] Only if the verification string matches. if ( stricmp ( currentServer->MasterBanlistVerificationString.c_str(), newServer.MasterBanlistVerificationString.c_str() ) == 0 ) { currentServer->lLastReceived = g_lCurrentTime; // [BB] The server possibly changed the ban setting, so update it. currentServer->bEnforcesBanList = newServer.bEnforcesBanList; } } // Ignore IP for 10 seconds. // if ( !g_MultiServerExceptions.isIPInList( Address ) ) // g_floodProtectionIPQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr ); return; } case SERVER_MASTER_VERIFICATION: { SERVER_s newServer; newServer.Address = AddressFrom; newServer.MasterBanlistVerificationString = NETWORK_ReadString( pByteStream ); newServer.ServerVerificationInt = NETWORK_ReadLong( pByteStream ); std::set<SERVER_s, SERVERCompFunc>::iterator currentServer = g_UnverifiedServers.find ( newServer ); // [BB] Apparently, we didn't request any verification from this server, so ignore it. if ( currentServer == g_UnverifiedServers.end() ) return; if ( ( stricmp ( newServer.MasterBanlistVerificationString.c_str(), currentServer->MasterBanlistVerificationString.c_str() ) == 0 ) && ( newServer.ServerVerificationInt == currentServer->ServerVerificationInt ) ) { MASTERSERVER_AddServer( *currentServer, g_Servers ); g_UnverifiedServers.erase ( currentServer ); } return; } case SERVER_MASTER_BANLIST_RECEIPT: { SERVER_s server; server.Address = AddressFrom; server.MasterBanlistVerificationString = NETWORK_ReadString( pByteStream ); std::set<SERVER_s, SERVERCompFunc>::iterator currentServer = g_Servers.find ( server ); // [BB] We don't know the server. Just ignore it. if ( currentServer == g_Servers.end() ) return; if ( stricmp ( server.MasterBanlistVerificationString.c_str(), currentServer->MasterBanlistVerificationString.c_str() ) == 0 ) { currentServer->bVerifiedLatestBanList = true; std::cerr << NETWORK_AddressToString ( AddressFrom ) << " acknowledged receipt of the banlist.\n"; } } return; // Launcher is asking master server for server list. case LAUNCHER_SERVER_CHALLENGE: case LAUNCHER_MASTER_CHALLENGE: { NETWORK_ClearBuffer( &g_MessageBuffer ); // Did this IP query us recently? If so, send it an explanation, and ignore it completely for 3 seconds. if ( g_queryIPQueue.addressInQueue( AddressFrom )) { NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_REQUESTIGNORED ); NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); printf( "* Extra launcher challenge from %s. Ignoring for 3 seconds.\n", NETWORK_AddressToString( AddressFrom )); g_ShortFloodQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr ); return; } // [BB] The launcher only sends the protocol version with LAUNCHER_MASTER_CHALLENGE. if ( lCommand == LAUNCHER_MASTER_CHALLENGE ) { // [BB] Check if the requested version of the protocol matches ours. const unsigned short usVersion = NETWORK_ReadShort( pByteStream ); if ( usVersion != MASTER_SERVER_VERSION ) { NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_WRONGVERSION ); NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); return; } } printf( "-> Sending server list to %s.\n", NETWORK_AddressToString( AddressFrom )); // Wait 10 seconds before sending this IP the server list again. g_queryIPQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr ); switch ( lCommand ) { case LAUNCHER_SERVER_CHALLENGE: // Send the list of servers. NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_BEGINSERVERLIST ); for( std::set<SERVER_s, SERVERCompFunc>::const_iterator it = g_Servers.begin(); it != g_Servers.end(); ++it ) { // [BB] Possibly omit servers that don't enforce our ban list. if ( ( it->bEnforcesBanList == true ) || ( g_bHideBanIgnoringServers == false ) ) MASTERSERVER_SendServerIPToLauncher ( it->Address, &g_MessageBuffer.ByteStream ); } // Tell the launcher that we're done sending servers. NETWORK_WriteByte( &g_MessageBuffer.ByteStream, MSC_ENDSERVERLIST ); // Send the launcher our packet. NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); return; case LAUNCHER_MASTER_CHALLENGE: const unsigned long ulMaxPacketSize = 1024; unsigned long ulPacketNum = 0; std::set<SERVER_s, SERVERCompFunc>::const_iterator it = g_Servers.begin(); NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_BEGINSERVERLISTPART ); NETWORK_WriteByte( &g_MessageBuffer.ByteStream, ulPacketNum ); NETWORK_WriteByte( &g_MessageBuffer.ByteStream, MSC_SERVERBLOCK ); unsigned long ulSizeOfPacket = 6; // 4 (MSC_BEGINSERVERLISTPART) + 1 (0) + 1 (MSC_SERVERBLOCK) while ( it != g_Servers.end() ) { NETADDRESS_s serverAddress = it->Address; std::vector<USHORT> serverPortList; do { // [BB] Possibly omit servers that don't enforce our ban list. if ( ( it->bEnforcesBanList == true ) || ( g_bHideBanIgnoringServers == false ) ) serverPortList.push_back ( it->Address.usPort ); ++it; } while ( ( it != g_Servers.end() ) && NETWORK_CompareAddress( it->Address, serverAddress, true ) ); // [BB] All servers on this IP ignore the list, nothing to send. if ( serverPortList.size() == 0 ) continue; const unsigned long ulServerBlockNetSize = MASTERSERVER_CalcServerIPBlockNetSize( serverAddress, serverPortList ); // [BB] If sending this block would cause the current packet to exceed ulMaxPacketSize ... if ( ulSizeOfPacket + ulServerBlockNetSize > ulMaxPacketSize - 1 ) { // [BB] ... close the current packet and start a new one. NETWORK_WriteByte( &g_MessageBuffer.ByteStream, 0 ); // [BB] Terminate MSC_SERVERBLOCK by sending 0 ports. NETWORK_WriteByte( &g_MessageBuffer.ByteStream, MSC_ENDSERVERLISTPART ); NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); NETWORK_ClearBuffer( &g_MessageBuffer ); ++ulPacketNum; ulSizeOfPacket = 5; NETWORK_WriteLong( &g_MessageBuffer.ByteStream, MSC_BEGINSERVERLISTPART ); NETWORK_WriteByte( &g_MessageBuffer.ByteStream, ulPacketNum ); NETWORK_WriteByte( &g_MessageBuffer.ByteStream, MSC_SERVERBLOCK ); } ulSizeOfPacket += ulServerBlockNetSize; MASTERSERVER_SendServerIPBlockToLauncher ( serverAddress, serverPortList, &g_MessageBuffer.ByteStream ); } NETWORK_WriteByte( &g_MessageBuffer.ByteStream, 0 ); // [BB] Terminate MSC_SERVERBLOCK by sending 0 ports. NETWORK_WriteByte( &g_MessageBuffer.ByteStream, MSC_ENDSERVERLIST ); NETWORK_LaunchPacket( &g_MessageBuffer, AddressFrom ); return; } } } printf( "* Received unknown challenge (%ld) from %s. Ignoring for 10 seconds...\n", lCommand, NETWORK_AddressToString( AddressFrom )); g_floodProtectionIPQueue.addAddress( AddressFrom, g_lCurrentTime, &std::cerr ); }
void CheckLeakAutoVar::checkScope(const Token * const startToken, VarInfo *varInfo, std::set<unsigned int> notzero) { std::map<unsigned int, int> &alloctype = varInfo->alloctype; std::map<unsigned int, std::string> &possibleUsage = varInfo->possibleUsage; const std::set<unsigned int> conditionalAlloc(varInfo->conditionalAlloc); // Parse all tokens const Token * const endToken = startToken->link(); for (const Token *tok = startToken; tok && tok != endToken; tok = tok->next()) { // Deallocation and then dereferencing pointer.. if (tok->varId() > 0) { const std::map<unsigned int, int>::iterator var = alloctype.find(tok->varId()); if (var != alloctype.end()) { if (var->second == DEALLOC && !Token::Match(tok->previous(), "[;{},=] %var% =")) { deallocUseError(tok, tok->str()); } else if (Token::simpleMatch(tok->tokAt(-2), "= &")) { varInfo->erase(tok->varId()); } else if (tok->strAt(-1) == "=") { varInfo->erase(tok->varId()); } } else if (Token::Match(tok->previous(), "& %var% = %var% ;")) { varInfo->referenced.insert(tok->tokAt(2)->varId()); } } if (tok->str() == "(" && tok->previous()->isName()) { functionCall(tok->previous(), varInfo, NOALLOC); tok = tok->link(); continue; } // look for end of statement if (!Token::Match(tok, "[;{}]") || Token::Match(tok->next(), "[;{}]")) continue; tok = tok->next(); if (!tok || tok == endToken) break; // parse statement // assignment.. if (tok->varId() && Token::Match(tok, "%var% =")) { // taking address of another variable.. if (Token::Match(tok->next(), "= %var% [+;]")) { if (tok->tokAt(2)->varId() != tok->varId()) { // If variable points at allocated memory => error leakIfAllocated(tok, *varInfo); // no multivariable checking currently => bail out for rhs variables for (const Token *tok2 = tok; tok2; tok2 = tok2->next()) { if (tok2->str() == ";") { break; } if (tok2->varId()) { varInfo->erase(tok2->varId()); } } } } // is variable used in rhs? bool used_in_rhs = false; for (const Token *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next()) { if (tok2->str() == ";") { break; } if (tok->varId() == tok2->varId()) { used_in_rhs = true; break; } } // TODO: Better checking how the pointer is used in rhs? if (used_in_rhs) continue; // Variable has already been allocated => error if (conditionalAlloc.find(tok->varId()) == conditionalAlloc.end()) leakIfAllocated(tok, *varInfo); varInfo->erase(tok->varId()); // not a local variable nor argument? const Variable *var = tok->variable(); if (var && !var->isArgument() && !var->isLocal()) { continue; } // Don't check reference variables if (var && var->isReference()) continue; // allocation? if (Token::Match(tok->tokAt(2), "%type% (")) { int i = _settings->library.alloc(tok->tokAt(2)); if (i > 0) { alloctype[tok->varId()] = i; } } // Assigning non-zero value variable. It might be used to // track the execution for a later if condition. if (Token::Match(tok->tokAt(2), "%num% ;") && MathLib::toLongNumber(tok->strAt(2)) != 0) notzero.insert(tok->varId()); else if (Token::Match(tok->tokAt(2), "- %type% ;") && tok->tokAt(3)->isUpperCaseName()) notzero.insert(tok->varId()); else notzero.erase(tok->varId()); } // if/else else if (Token::simpleMatch(tok, "if (")) { // Parse function calls inside the condition for (const Token *innerTok = tok->tokAt(2); innerTok; innerTok = innerTok->next()) { if (innerTok->str() == ")") break; if (innerTok->str() == "(" && innerTok->previous()->isName()) { const int deallocId = _settings->library.dealloc(tok); functionCall(innerTok->previous(), varInfo, deallocId); innerTok = innerTok->link(); } } const Token *tok2 = tok->linkAt(1); if (Token::simpleMatch(tok2, ") {")) { VarInfo varInfo1(*varInfo); // VarInfo for if code VarInfo varInfo2(*varInfo); // VarInfo for else code if (Token::Match(tok->next(), "( %var% )")) { varInfo2.erase(tok->tokAt(2)->varId()); if (notzero.find(tok->tokAt(2)->varId()) != notzero.end()) varInfo2.clear(); } else if (Token::Match(tok->next(), "( ! %var% )|&&")) { varInfo1.erase(tok->tokAt(3)->varId()); } else if (Token::Match(tok->next(), "( %var% ( ! %var% ) )|&&")) { varInfo1.erase(tok->tokAt(5)->varId()); } else if (Token::Match(tok->next(), "( %var% < 0 )|&&")) { varInfo1.erase(tok->tokAt(2)->varId()); } else if (Token::Match(tok->next(), "( 0 > %var% )|&&")) { varInfo1.erase(tok->tokAt(4)->varId()); } else if (Token::Match(tok->next(), "( %var% > 0 )|&&")) { varInfo2.erase(tok->tokAt(2)->varId()); } else if (Token::Match(tok->next(), "( 0 < %var% )|&&")) { varInfo2.erase(tok->tokAt(4)->varId()); } checkScope(tok2->next(), &varInfo1, notzero); tok2 = tok2->linkAt(1); if (Token::simpleMatch(tok2, "} else {")) { checkScope(tok2->tokAt(2), &varInfo2, notzero); tok = tok2->linkAt(2)->previous(); } else { tok = tok2->previous(); } VarInfo old; old.swap(*varInfo); // Conditional allocation in varInfo1 std::map<unsigned int, int>::const_iterator it; for (it = varInfo1.alloctype.begin(); it != varInfo1.alloctype.end(); ++it) { if (varInfo2.alloctype.find(it->first) == varInfo2.alloctype.end() && old.alloctype.find(it->first) == old.alloctype.end()) { varInfo->conditionalAlloc.insert(it->first); } } // Conditional allocation in varInfo2 for (it = varInfo2.alloctype.begin(); it != varInfo2.alloctype.end(); ++it) { if (varInfo1.alloctype.find(it->first) == varInfo1.alloctype.end() && old.alloctype.find(it->first) == old.alloctype.end()) { varInfo->conditionalAlloc.insert(it->first); } } // Conditional allocation/deallocation for (it = varInfo1.alloctype.begin(); it != varInfo1.alloctype.end(); ++it) { if (it->second == DEALLOC && conditionalAlloc.find(it->first) != conditionalAlloc.end()) { varInfo->conditionalAlloc.erase(it->first); varInfo2.erase(it->first); } } for (it = varInfo2.alloctype.begin(); it != varInfo2.alloctype.end(); ++it) { if (it->second == DEALLOC && conditionalAlloc.find(it->first) != conditionalAlloc.end()) { varInfo->conditionalAlloc.erase(it->first); varInfo1.erase(it->first); } } alloctype.insert(varInfo1.alloctype.begin(), varInfo1.alloctype.end()); alloctype.insert(varInfo2.alloctype.begin(), varInfo2.alloctype.end()); possibleUsage.insert(varInfo1.possibleUsage.begin(), varInfo1.possibleUsage.end()); possibleUsage.insert(varInfo2.possibleUsage.begin(), varInfo2.possibleUsage.end()); } } // unknown control.. else if (Token::Match(tok, "%type% (") && Token::simpleMatch(tok->linkAt(1), ") {")) { varInfo->clear(); break; } // Function call.. else if (Token::Match(tok, "%type% (") && tok->str() != "return") { const int dealloc = _settings->library.dealloc(tok); functionCall(tok, varInfo, dealloc); tok = tok->next()->link(); // Handle scopes that might be noreturn if (dealloc == NOALLOC && Token::simpleMatch(tok, ") ; }")) { const std::string &functionName(tok->link()->previous()->str()); bool unknown = false; if (_tokenizer->IsScopeNoReturn(tok->tokAt(2), &unknown)) { if (!unknown) varInfo->clear(); else if (_settings->library.leakignore.find(functionName) == _settings->library.leakignore.end() && _settings->library.use.find(functionName) == _settings->library.use.end()) varInfo->possibleUsageAll(functionName); } } continue; } // return else if (tok->str() == "return") { ret(tok, *varInfo); varInfo->clear(); } // goto => weird execution path else if (tok->str() == "goto") { varInfo->clear(); } // continue/break else if (Token::Match(tok, "continue|break ;")) { varInfo->clear(); } // throw // TODO: if the execution leave the function then treat it as return else if (tok->str() == "throw") { varInfo->clear(); } } }
void GotWrapped(Unit* unit) { if (unit && unit->GetTypeId() == TYPEID_PLAYER) lUnWrappedPlayers.erase(unit->GetGUID()); }
/* * Class: CSet * Method: c_remove * Signature: (Ljava/lang/Object;)Z */ JNIEXPORT jboolean JNICALL Java_CSet_c_1remove(JNIEnv *env, jobject obj, jstring element) { return set.erase(strFromJString(env, element)); }
void CrackFrontDefinition::getCrackFrontNodes(std::set<unsigned int>& nodes) { ConstBndNodeRange & bnd_nodes = *_mesh.getBoundaryNodeRange(); for (ConstBndNodeRange::const_iterator nd = bnd_nodes.begin() ; nd != bnd_nodes.end(); ++nd) { const BndNode * bnode = *nd; BoundaryID boundary_id = bnode->_bnd_id; if (hasBoundary(boundary_id)) { nodes.insert(bnode->_node->id()); } } if (_treat_as_2d) { if (nodes.size() > 1) { //Delete all but one node if they are collinear in the axis normal to the 2d plane unsigned int axis0; unsigned int axis1; switch (_axis_2d) { case 0: axis0 = 1; axis1 = 2; break; case 1: axis0 = 0; axis1 = 2; break; case 2: axis0 = 0; axis1 = 1; break; } Real node0coor0; Real node0coor1; for (std::set<unsigned int>::iterator sit=nodes.begin(); sit != nodes.end(); ++sit) { Node & curr_node = _mesh.node(*sit); if (sit == nodes.begin()) { node0coor0 = curr_node(axis0); node0coor1 = curr_node(axis1); } else { if ((std::abs(curr_node(axis0) - node0coor0) > _tol) || (std::abs(curr_node(axis1) - node0coor1) > _tol)) { mooseError("Boundary provided in CrackFrontDefinition contains "<<nodes.size()<<" nodes, which are not collinear in the "<<_axis_2d<<" axis. Must contain either 1 node or collinear nodes to treat as 2D."); } } } std::set<unsigned int>::iterator second_node = nodes.begin(); ++second_node; nodes.erase(second_node,nodes.end()); } } }
void IntSet::Remove(int val) { m_set.erase(val); }
void block_construction_finished ( void *block ) { floating_blocks_iterator it = m_floating_blocks.find ( block ); assert ( it != m_floating_blocks.end() ); m_floating_blocks.erase ( it ); }
void erase(MessagingPort* p) { stdx::lock_guard<stdx::mutex> bl(m); ports.erase(p); }
void WaypointManager::CheckTextsExistance(std::set<int32>& ids) { WaypointPathMap::const_iterator pmItr = m_pathMap.begin(); for ( ; pmItr != m_pathMap.end(); ++pmItr) { for (size_t i = 0; i < pmItr->second.size(); ++i) { WaypointBehavior* be = pmItr->second[i].behavior; if (!be) continue; // Now we check text existence and put all zero texts ids to the end of array // Counting leading zeros for futher textid shift int zeroCount = 0; for (int j = 0; j < MAX_WAYPOINT_TEXT; ++j) { if (!be->textid[j]) { ++zeroCount; continue; } else { if (!sObjectMgr.GetMangosStringLocale(be->textid[j])) { sLog.outErrorDb("Some waypoint has textid%u with not existing %u text.", j, be->textid[j]); be->textid[j] = 0; ++zeroCount; continue; } else ids.erase(be->textid[j]); // Shifting check if (zeroCount) { // Correct textid but some zeros leading, so move it forward. be->textid[j-zeroCount] = be->textid[j]; be->textid[j] = 0; } } } } } WaypointPathTemplateMap::const_iterator wptItr = m_pathTemplateMap.begin(); for ( ; wptItr != m_pathTemplateMap.end(); ++wptItr) { for (size_t i = 0; i < wptItr->second.size(); ++i) { WaypointBehavior* be = wptItr->second[i].behavior; if (!be) continue; // Now we check text existence and put all zero texts ids to the end of array // Counting leading zeros for futher textid shift int zeroCount = 0; for (int j = 0; j < MAX_WAYPOINT_TEXT; ++j) { if (!be->textid[j]) { ++zeroCount; continue; } else { if (!sObjectMgr.GetMangosStringLocale(be->textid[j])) { sLog.outErrorDb("Some waypoint has textid%u with not existing %u text.", j, be->textid[j]); be->textid[j] = 0; ++zeroCount; continue; } else ids.erase(be->textid[j]); // Shifting check if (zeroCount) { // Correct textid but some zeros leading, so move it forward. be->textid[j-zeroCount] = be->textid[j]; be->textid[j] = 0; } } } } } }
void find_next_edge(Segment s, std::vector<Segment>& segments, std::set<int>& unusedIndexes, std::vector<Polygon_2>& rings) { if(unusedIndexes.empty() || prev_size == unusedIndexes.size()) { return; } prev_size = unusedIndexes.size(); Point start = s.source(); Point end = s.target(); rings.back().push_back(end); std::vector<int> nextIndexes; for(unsigned int i = 0;i < segments.size(); i++) { if (unusedIndexes.find(i) != unusedIndexes.end()) { Point source = segments.at(i).source(); if(source == end) { nextIndexes.push_back(i); } } } if (nextIndexes.size() == 1) { int i = nextIndexes.at(0); unusedIndexes.erase(i); find_next_edge(segments.at(i), segments, unusedIndexes, rings); } else if (nextIndexes.size() > 1) { std::vector< std::pair<double, int> > nextAngles; for (unsigned int i = 0; i < nextIndexes.size(); i++) { int j = nextIndexes.at(i); Point target = segments.at(j).target(); double angle = get_angle(start, end, target); nextAngles.push_back(std::pair<double, int>(angle, j)); } std::sort(nextAngles.begin(), nextAngles.end()); int i = nextAngles.begin()->second; unusedIndexes.erase(i); find_next_edge(segments.at(i), segments, unusedIndexes, rings); } if (!unusedIndexes.empty()) { for (unsigned int i = 0; i < segments.size(); i++) { if (unusedIndexes.find(i) != unusedIndexes.end()) { Polygon_2 ring; ring.push_back(segments.at(i).source()); rings.push_back(ring); unusedIndexes.erase(i); find_next_edge(segments.at(i), segments, unusedIndexes, rings); } } } }
bool find_sql_updates() { printf("+ finding new sql updates on HEAD\n"); // add all updates from HEAD snprintf(cmd, MAX_CMD, "git show HEAD:%s", sql_update_dir); if( (cmd_pipe = popen( cmd, "r" )) == NULL ) return false; // skip first two lines if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } sql_update_info info; while(fgets(buffer, MAX_BUF, cmd_pipe)) { buffer[strlen(buffer) - 1] = '\0'; if(!get_sql_update_info(buffer, info)) continue; if(info.db_idx == NUM_DATABASES) { if(info.rev > 0) printf("WARNING: incorrect database name for sql update %s\n", buffer); continue; } new_sql_updates.insert(buffer); } pclose(cmd_pipe); // Add last milestone's file information last_sql_rev[0] = 11785; last_sql_nr[0] = 2; sscanf("11785_02_characters_instance", "%s", last_sql_update[0]); last_sql_rev[2] = 10008; last_sql_nr[2] = 1; sscanf("10008_01_realmd_realmd_db_version", "%s", last_sql_update[2]); // remove updates from the last commit also found on origin snprintf(cmd, MAX_CMD, "git show %s:%s", origin_hash, sql_update_dir); if( (cmd_pipe = popen( cmd, "r" )) == NULL ) return false; // skip first two lines if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } if(!fgets(buffer, MAX_BUF, cmd_pipe)) { pclose(cmd_pipe); return false; } while(fgets(buffer, MAX_BUF, cmd_pipe)) { buffer[strlen(buffer) - 1] = '\0'; if(!get_sql_update_info(buffer, info)) continue; // find the old update with the highest rev for each database // (will be the required version for the new update) std::set<std::string>::iterator itr = new_sql_updates.find(buffer); if(itr != new_sql_updates.end() ) { if(info.rev > 0 && (info.rev > last_sql_rev[info.db_idx] || (info.rev == last_sql_rev[info.db_idx] && info.nr > last_sql_nr[info.db_idx]))) { last_sql_rev[info.db_idx] = info.rev; last_sql_nr[info.db_idx] = info.nr; sscanf(buffer, "%[^.]", last_sql_update[info.db_idx]); } new_sql_updates.erase(itr); } } pclose(cmd_pipe); if(!new_sql_updates.empty()) { for(std::set<std::string>::iterator itr = new_sql_updates.begin(); itr != new_sql_updates.end(); ++itr) printf("%s\n", itr->c_str()); } else printf("WARNING: no new sql updates found.\n"); return true; }
static void url_encode_array(StringBuffer &ret, const Variant& varr, std::set<void*> &seen_arrs, const String& num_prefix, const String& key_prefix, const String& key_suffix, const String& arg_sep, bool encode_plus = true) { void *id = varr.isArray() ? (void*)varr.getArrayData() : (void*)varr.getObjectData(); if (!seen_arrs.insert(id).second) { return; // recursive } // Allow multiple non-recursive references to the same array/object SCOPE_EXIT { seen_arrs.erase(id); }; Array arr; if (varr.is(KindOfObject)) { Object o = varr.toObject(); arr = o->isCollection() ? varr.toArray() : HHVM_FN(get_object_vars(o)); } else { arr = varr.toArray(); } for (ArrayIter iter(arr); iter; ++iter) { Variant data = iter.second(); if (data.isNull() || data.isResource()) continue; String key = iter.first(); bool numeric = key.isNumeric(); if (data.isArray() || data.is(KindOfObject)) { String encoded; if (numeric) { encoded = key; } else { encoded = StringUtil::UrlEncode(key, encode_plus); } StringBuffer new_prefix(key_prefix.size() + num_prefix.size() + encoded.size() + key_suffix.size() + 4); new_prefix.append(key_prefix); if (numeric) new_prefix.append(num_prefix); new_prefix.append(encoded); new_prefix.append(key_suffix); new_prefix.append("%5B"); url_encode_array(ret, data, seen_arrs, String(), new_prefix.detach(), String("%5D", CopyString), arg_sep); } else { if (!ret.empty()) { ret.append(arg_sep); } ret.append(key_prefix); if (numeric) { ret.append(num_prefix); ret.append(key); } else { ret.append(StringUtil::UrlEncode(key, encode_plus)); } ret.append(key_suffix); ret.append("="); if (data.isInteger() || data.is(KindOfBoolean)) { ret.append(String(data.toInt64())); } else if (data.is(KindOfDouble)) { ret.append(String(data.toDouble())); } else { ret.append(StringUtil::UrlEncode(data.toString(), encode_plus)); } } } }
void gxFileSystem::closeDir(gxDir* d) { if (dir_set.erase(d)) delete d; }
void CheckLeakAutoVar::checkScope(const Token * const startToken, VarInfo *varInfo, std::set<unsigned int> notzero) { std::map<unsigned int, std::string> &alloctype = varInfo->alloctype; std::map<unsigned int, std::string> &possibleUsage = varInfo->possibleUsage; const std::set<unsigned int> conditionalAlloc(varInfo->conditionalAlloc); // Allocation functions. key = function name, value = allocation type std::map<std::string, std::string> allocFunctions(cfgalloc); allocFunctions["malloc"] = "malloc"; allocFunctions["strdup"] = "malloc"; allocFunctions["fopen"] = "fopen"; // Deallocation functions. key = function name, value = allocation type std::map<std::string, std::string> deallocFunctions(cfgdealloc); deallocFunctions["free"] = "malloc"; deallocFunctions["fclose"] = "fopen"; // Parse all tokens const Token * const endToken = startToken->link(); for (const Token *tok = startToken; tok && tok != endToken; tok = tok->next()) { // Deallocation and then dereferencing pointer.. if (tok->varId() > 0) { const std::map<unsigned int, std::string>::iterator var = alloctype.find(tok->varId()); if (var != alloctype.end()) { if (var->second == "dealloc" && !Token::Match(tok->previous(), "[;{},=] %var% =")) { deallocUseError(tok, tok->str()); } else if (Token::simpleMatch(tok->tokAt(-2), "= &")) { varInfo->erase(tok->varId()); } else if (Token::simpleMatch(tok->previous(), "=")) { varInfo->erase(tok->varId()); } } } if (tok->str() == "(" && tok->previous()->isName()) { functionCall(tok->previous(), varInfo, ""); tok = tok->link(); continue; } // look for end of statement if (!Token::Match(tok, "[;{}]") || Token::Match(tok->next(), "[;{}]")) continue; tok = tok->next(); if (tok == endToken) break; // parse statement // assignment.. if (tok && tok->varId() && Token::Match(tok, "%var% =")) { // taking address of another variable.. if (Token::Match(tok->next(), "= %var% [+;]")) { if (tok->tokAt(2)->varId() != tok->varId()) { // If variable points at allocated memory => error leakIfAllocated(tok, *varInfo); // no multivariable checking currently => bail out for rhs variables for (const Token *tok2 = tok; tok2; tok2 = tok2->next()) { if (tok2->str() == ";") { break; } if (tok2->varId()) { varInfo->erase(tok2->varId()); } } } } // is variable used in rhs? bool used_in_rhs = false; for (const Token *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next()) { if (tok2->str() == ";") { break; } if (tok->varId() == tok2->varId()) { used_in_rhs = true; break; } } // TODO: Better checking how the pointer is used in rhs? if (used_in_rhs) continue; // Variable has already been allocated => error if (conditionalAlloc.find(tok->varId()) == conditionalAlloc.end()) leakIfAllocated(tok, *varInfo); varInfo->erase(tok->varId()); // not a local variable nor argument? const Variable *var = _tokenizer->getSymbolDatabase()->getVariableFromVarId(tok->varId()); if (var && !var->isArgument() && !var->isLocal()) { continue; } // Don't check reference variables if (var && var->isReference()) continue; // allocation? if (Token::Match(tok->tokAt(2), "%type% (")) { const std::map<std::string, std::string>::const_iterator it = allocFunctions.find(tok->strAt(2)); if (it != allocFunctions.end()) { alloctype[tok->varId()] = it->second; } } // Assigning non-zero value variable. It might be used to // track the execution for a later if condition. if (Token::Match(tok->tokAt(2), "%num% ;") && MathLib::toLongNumber(tok->strAt(2)) != 0) notzero.insert(tok->varId()); else if (Token::Match(tok->tokAt(2), "- %type% ;") && tok->tokAt(3)->isUpperCaseName()) notzero.insert(tok->varId()); else notzero.erase(tok->varId()); } // if/else else if (Token::simpleMatch(tok, "if (")) { // Parse function calls inside the condition for (const Token *innerTok = tok->tokAt(2); innerTok; innerTok = innerTok->next()) { if (innerTok->str() == ")") break; if (innerTok->str() == "(" && innerTok->previous()->isName()) { std::string dealloc; { const std::map<std::string, std::string>::iterator func = deallocFunctions.find(tok->str()); if (func != deallocFunctions.end()) { dealloc = func->second; } } functionCall(innerTok->previous(), varInfo, dealloc); innerTok = innerTok->link(); } } const Token *tok2 = tok->linkAt(1); if (Token::simpleMatch(tok2, ") {")) { VarInfo varInfo1(*varInfo); VarInfo varInfo2(*varInfo); if (Token::Match(tok->next(), "( %var% )")) { varInfo2.erase(tok->tokAt(2)->varId()); if (notzero.find(tok->tokAt(2)->varId()) != notzero.end()) varInfo2.clear(); } else if (Token::Match(tok->next(), "( ! %var% )|&&")) { varInfo1.erase(tok->tokAt(3)->varId()); } else if (Token::Match(tok->next(), "( %var% ( ! %var% ) )|&&")) { varInfo1.erase(tok->tokAt(5)->varId()); } checkScope(tok2->next(), &varInfo1, notzero); tok2 = tok2->linkAt(1); if (Token::simpleMatch(tok2, "} else {")) { checkScope(tok2->tokAt(2), &varInfo2, notzero); tok = tok2->linkAt(2)->previous(); } else { tok = tok2->previous(); } VarInfo old; old.swap(*varInfo); // Conditional allocation in varInfo1 std::map<unsigned int, std::string>::const_iterator it; for (it = varInfo1.alloctype.begin(); it != varInfo1.alloctype.end(); ++it) { if (varInfo2.alloctype.find(it->first) == varInfo2.alloctype.end() && old.alloctype.find(it->first) == old.alloctype.end()) { varInfo->conditionalAlloc.insert(it->first); } } // Conditional allocation in varInfo2 for (it = varInfo2.alloctype.begin(); it != varInfo2.alloctype.end(); ++it) { if (varInfo1.alloctype.find(it->first) == varInfo1.alloctype.end() && old.alloctype.find(it->first) == old.alloctype.end()) { varInfo->conditionalAlloc.insert(it->first); } } // Conditional allocation/deallocation for (it = varInfo1.alloctype.begin(); it != varInfo1.alloctype.end(); ++it) { if (it->second == "dealloc" && conditionalAlloc.find(it->first) != conditionalAlloc.end()) { varInfo->conditionalAlloc.erase(it->first); varInfo2.erase(it->first); } } for (it = varInfo2.alloctype.begin(); it != varInfo2.alloctype.end(); ++it) { if (it->second == "dealloc" && conditionalAlloc.find(it->first) != conditionalAlloc.end()) { varInfo->conditionalAlloc.erase(it->first); varInfo1.erase(it->first); } } alloctype.insert(varInfo1.alloctype.begin(), varInfo1.alloctype.end()); alloctype.insert(varInfo2.alloctype.begin(), varInfo2.alloctype.end()); possibleUsage.insert(varInfo1.possibleUsage.begin(), varInfo1.possibleUsage.end()); possibleUsage.insert(varInfo2.possibleUsage.begin(), varInfo2.possibleUsage.end()); } } // unknown control.. else if (Token::Match(tok, "%type% (") && Token::simpleMatch(tok->linkAt(1), ") {")) { varInfo->clear(); break; } // Function call.. else if (Token::Match(tok, "%type% (") && tok->str() != "return") { std::string dealloc; { const std::map<std::string, std::string>::iterator func = deallocFunctions.find(tok->str()); if (func != deallocFunctions.end()) { dealloc = func->second; } } functionCall(tok, varInfo, dealloc); tok = tok->next()->link(); // Handle scopes that might be noreturn if (dealloc.empty() && Token::simpleMatch(tok, ") ; }")) { const std::string &functionName(tok->link()->previous()->str()); bool unknown = false; if (cfgignore.find(functionName) == cfgignore.end() && cfguse.find(functionName) == cfguse.end() && _tokenizer->IsScopeNoReturn(tok->tokAt(2), &unknown)) { if (unknown) { //const std::string &functionName(tok->link()->previous()->str()); varInfo->possibleUsageAll(functionName); } else { varInfo->clear(); } } } continue; } // return else if (tok->str() == "return" || tok->str() == "throw") { ret(tok, *varInfo); varInfo->clear(); } } }
void consume( state s ) { states.erase( s ); }
void ResumeMonitoringOnFile(const char* filepath){ auto it = mIgnoreFileChanges.find(filepath); if (it != mIgnoreFileChanges.end()) mIgnoreFileChanges.erase(it); }
void std_node_t::remove(int fd) { clients.erase(fd); }
static InitFunction initFunction([] () { static std::set<std::string> g_textChatDisableResources; fx::ScriptEngine::RegisterNativeHandler("SET_TEXT_CHAT_ENABLED", [] (fx::ScriptContext& context) { fx::OMPtr<IScriptRuntime> runtime; if (FX_SUCCEEDED(fx::GetCurrentScriptRuntime(&runtime))) { fx::Resource* resource = reinterpret_cast<fx::Resource*>(runtime->GetParentObject()); auto tryEnableForResource = [=] () { // erase the resource and see if the list is empty - if so, enable chat g_textChatDisableResources.erase(resource->GetName()); // check if empty if (g_textChatDisableResources.empty()) { game::SetTextChatEnabled(true); } }; if (resource) { bool enabled = context.GetArgument<bool>(0); // if it's already disabled by this resource if (g_textChatDisableResources.find(resource->GetName()) != g_textChatDisableResources.end()) {