void SymbolManager::cleanFunctions() { this->funcListMutex.lock(); for (auto &item : this->funcList) { assert(item); item->updateTypes(); } auto item = this->funcList.begin(); std::sort( item, funcList.end(), [](const Function *a, const Function *b) { return *a < *b; } ); item = this->funcList.begin(); if (item == this->funcList.end()) { return; } Function *oldPtr = *item; Function *delPtr = nullptr; item++; FuncList tmp; while (item != funcList.end()) { if (*oldPtr == *(*item)) { delPtr = *item; this->addAlternativeID(oldPtr->getID(), delPtr->getID()); delete delPtr; } else { tmp.push_back(*item); oldPtr = (*item); } item++; } tmp.shrink_to_fit(); this->funcList.swap(tmp); tmp.clear(); // TODO actually we don't need the vector any more at this point this->funcListMutex.unlock(); }